- The location is the path where the snapshots will be stored, this path need to be set in the elasticsearch.yml file in the path.repo property
- example: path.repo: ["/usr/share/elasticsearch/backup"]
- After setting the path.repo property in the elasticsearch.yml file, restart the elasticsearch service
curl -XPUT -k -u elastic:changeme "https://localhost:9200/_snapshot/repository_backups" -H 'Content-Type: application/json' -d '{
"type": "fs",
"settings": {
"location": "/usr/share/elasticsearch/backup"
}
}'
Execute the following command to create a snapshot of the cluster state:
./create_snapshot.sh
The name of the snapshot is the date and time when the snapshot was created.
First,you need the name of the snapshot you want to restore. You can get the list of snapshots by executing the following command:
curl -XGET -k -u elastic:changeme "https://localhost:9200/_snapshot/repository_backups/_all"
Execute the following command to restore a snapshot of the cluster state:
curl -XPOST -k -u elastic:changeme "https://localhost:9200/_snapshot/repository_backups/snapshot_1/_restore"
# snapshot_1 is the name of the snapshot in the list of snapshots
curl -XGET -k -u elastic:changeme "https://localhost:9200/_snapshot/repository_backups/snapshot_1"
curl -XGET -k -u elastic:changeme "https://localhost:9200/_snapshot/repository_backups/_all"
curl -XDELETE -k -u elastic:changeme "https://localhost:9200/_snapshot/repository_backups/snapshot_1"
curl -XDELETE -k -u elastic:changeme "https://localhost:9200/_snapshot/repository_backups"
For restore the snapshots in other cluster, you need to create the repository in the other cluster and then restore the snapshot
- Compres the backup folder and copy it to the other cluster
tar -czvf backup.tar.gz /usr/share/elasticsearch/backup
scp backup.tar.gz user@ip:/path
- Extract the backup folder in the other cluster
tar -xzvf backup.tar.gz
- Create the repository in the other cluster, same as the first cluster
- Follow the steps to restore the snapshot