Sunday, March 30, 2014

Intro to Elasticsearch and New Features in version 1.0.x (Snapshot and Restore)

These are the notes from my presentation: http://www.meetup.com/Elasticsearch-Philadelphia/events/164506092/

http://youtu.be/6Idi13rQx1o?t=40m30s

Snapshot and restore is a great way to save your data in case of an accidental deletion or full cluster loss.   Below I walk through an example of snapshot and restore. It assumes you have an index philly_energy.

Create back up folder
$ curl -XPUT 'http://localhost:9200/_snapshot/my_backup' -d '{
    "type": "fs",
    "settings": {
        "location": "/tmp/mount/backups/my_backup",
        "compress": true
    }
}'


{"acknowledged":true}

Get backups
$ curl -XGET "localhost:9200/_snapshot/my_backup/_all"


{"snapshots":[]}

Take backup
$ curl -XPUT "localhost:9200/_snapshot/my_backup/snapshot_1" -d '{
    "indices": "philly_energy",
    "ignore_unavailable": "true",
    "include_global_state": false
}'


{"accepted":true}

Get backups
$ curl -XGET "localhost:9200/_snapshot/my_backup/_all"

{"snapshots":[{"snapshot":"snapshot_1","indices":["philly_energy"],"state":"SUCCESS","start_time":"2014-03-28T02:11:07.740Z","start_time_in_millis":1395972667740,"end_time":"2014-03-28T02:11:07.882Z","end_time_in_millis":1395972667882,"duration_in_millis":142,"failures":[],"shards":{"total":5,"failed":0,"successful":5}}]}

Drop index
$ curl -X DELETE 'http://localhost:9200/philly_energy'

{"acknowledged":true}

Restore
$ curl -XPOST "localhost:9200/_snapshot/my_backup/snapshot_1/_restore"

{"accepted":true}

No comments:

Post a Comment