...
Ensure that the location path is accessible and writable by all nodes in the cluster.
NOTE: The shared repository location will have to be specified in the elasticsearch.yml
file as a “path.repo
” parameter:
path.repo: "/mount/backups/my_backup"
Verify the Repository
After creating the repository, verify it to ensure it is set up correctly:
Code Block curl -X GET "http://<es_node_ip>:9200/_snapshot/my_backup"
Create a Snapshot
Once the repository is set up and verified, create a snapshot of your index. Replace
index_mumbkctcomobs.datacore.com.com0
with your index name.Code Block curl -X PUT "http://<es_node_ip>:9200/_snapshot/my_backup/snapshot_$(date +\%Y\%m\%d\%H\%M)" -H 'Content-Type: application/json' -d' { "indices": "index_mumbkctcomobsswarm.datacore.com.com0", "ignore_unavailable": true, "include_global_state": false }'
Automate Snapshot Creation
To automate the creation of snapshots, you can use cron jobs on Linux or scheduled tasks on Windows.
Example using a cron job (runs daily at 2 AM):
Code Block 0 2 * * * curl -X PUT "http://<es_node_ip>:9200/_snapshot/my_backup/snapshot_$(date +\%Y\%m\%d\%H\%M)" -H 'Content-Type: application/json' -d' { "indices": "index_mumbkctcomobsswarm.datacore.com.com0", "ignore_unavailable": true, "include_global_state": false }'
Monitor Snapshots
Regularly check the status of your snapshots to ensure they are completing successfully:
Code Block curl -X GET "http://<es_node_ip>:9200/_snapshot/my_backup/_all/_status"
Restoring a Snapshot (if needed)
If you need to restore a snapshot, you can do so with the following command:
Code Block curl -X POST "http://<es_node_ip>:9200/_snapshot/my_backup/snapshot_<snapshot_date>/_restore" -H 'Content-Type: application/json' -d' { "indices": "index_mumbkctcomobsswarm.datacore.com.com0", "ignore_unavailable": true, "include_global_state": false }'
NOTE:
"include_global_state": false
will mean that only the data that are stored in the particular index is restored.
But if we want to restored everything from the cluster right from templates, persistent cluster settings and all, we may have to enable the same by using"include_global_state": true
Automating with Elasticsearch Curator
...