These are steps to restore an elasticsearch snapshot from one machine to another
Copy zip of snapshot from s3
sudo mkdir /data
sudo chmod 777 -R /data
aws s3 cp "s3://enel-aws/elasticsearch_snapshots.zip" .
unzip elasticsearch_snapshots.zip -d /data/
Install opendistro for elasticsearch
Add the folder for snapshots to "/etc/elasticsearch/elasticsearch.yml"
path.repo: ["/data/elasticsearch_snapshot"]
Restart elasticsearch
sudo systemctl restart elasticsearch.service
Install kibana
- https://opendistro.github.io/for-elasticsearch-docs/docs/kibana/
- and login with defaults admin:admin
Go to Kibana "Dev tools" to run queries below
Test
GET /
Equivalent of curl call:
curl -u admin:admin --insecure -XGET https://localhost:9200
List repositories
GET _cat/repositories
# empty
Add repository
PUT _snapshot/my_fs_backup
{
"type": "fs",
"settings" : {
"compress" : "true",
"location" : "/data/elasticsearch_snapshots",
"max_snapshot_bytes_per_sec" : "5000mb"
}
or
curl -u admin:admin --insecure -H 'Content-Type: application/json' -XPUT \
https://localhost:9200/_snapshot/my_fs_backup \
-d '{
"type": "fs",
"settings": {
"location": "/data/elasticsearch_snapshot",
"compress": true
}
}'
List snapshots in repo
GET _cat/repositories
# my_fs_backup
List all snapshots in repository
GET /_snapshot/my_fs_backup/_all
{
"snapshots" : [
{
"snapshot" : "snapshot_1",
"uuid" : "dmAnazMrQtqsUYIrVt_WtQ",
"version_id" : 6050499,
"version" : "6.5.4",
"indices" : [
"modifyclusteriamroles_anon",
"deletetable_anon",
...
Restore from snapshot (doesnt work due to above empty list)
POST /_snapshot/my_fs_backup/snapshot_1/_restore
{
"indices": "*_anon",
"include_global_state": false
}