Backup elasticsearch with snapshot and restore api

Even if elasticsearch is distributed, highly available but it has some limitation over multiple data center. So creating DR of elasticsearch is some what tricky. So in this case backup of whole elasticsearch cluster is very important. With latest version of elasticsearch, snapshot and restore api included.

Here are following steps to backup your cluster and restore it on other location.

  1. First you need to create repository. For creating repository, you need to specify which type of it i.e. fs or url etc. Lets create  of type fs for now.
  2. If you selected fs then you must need to specify location where backup created.
  3. Make sure that path provided is location setting must be present on all of elasticsearch nodes with proper permissions.
  4. NFS mount point would be good in this case.

Create repo.

curl -XPUT 'http://localhost:9200/_snapshot/RepoName' -d '{
"type": "fs",
"settings": {
"location": "/path to the common dir on all nodes/xxx"
"max_snapshot_bytes_per_sec": "200mb"

Create Snapshot

curl -XPUT "localhost:9200/_snapshot/RepoName/snapshot_01_sept-2014-12-12-IST"

You can check status of snapshot as …

curl -XPUT "localhost:9200/_snapshot/RepoName/snapshot_01_sept-2014-12-12-ist/_status?pretty=1"

Get Snapshot

curl -XGET 'http://localhost:9200/_snapshot'


Restore snapshot

At the time of restore snapshot, you must need to make sure same repo will be present their and configure location path from that repo will be accessible from that server.

curl -XPOST "localhost:9200/_snapshot/ModeSearch/snapshot_01_sept-2014-12-12-ist/_restore"


Categories: Elasticsearch