Skip to content

Instantly share code, notes, and snippets.

@tkremmel
Last active December 2, 2015 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkremmel/e60d63b84bc1359e4dda to your computer and use it in GitHub Desktop.
Save tkremmel/e60d63b84bc1359e4dda to your computer and use it in GitHub Desktop.
elasticsearch snapshot and restore
# create a snapshot repository
curl -XPUT 'localhost:9200/_snapshot/my_snapshot' -d '
{
"type": "fs",
"settings": {
"location": "/var/data/elasticsearch/snapshots",
"compress": "true"
}
}'
# create a snapshot
curl -XPUT 'localhost:9200/_snapshot/my_snapshot/2015-12-03?pretty?wait_for_completion' -d '
{
"indices": "index1,index2",
"ignore_unavailable": "true",
"include_global_state": "false"
}'
# get snapshot status
curl -XGET 'localhost:9200/_snapshot/my_snapshot/2015-12-03?pretty'
# restore a snapshot
curl -XPOST 'localhost:9200/index1/_close' # close the indices if they are open
curl -XPOST 'localhost:9200/index2/_close' # close the indices if they are open
curl -XDELETE 'http://localhost:9200/index1/'
curl -XDELETE 'http://localhost:9200/index2/'
curl -XPOST 'localhost:9200/_snapshot/my_snapshot/2015-12-03/_restore?pretty'
# get a list of all snapshots
curl -s -XGET "localhost:9200/_snapshot/my_snapshot/_all?pretty"
# delete a snapshot
curl -XDELETE 'localhost:9200/_snapshot/my_snapshot/2015-12-03?pretty'
NOTE: Since v1.6 one has to add path.repo: ["/mount/backups", "/mount/longterm_backups"] configuration to the elasticsearch.yml file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment