Loading...

Snapshot and Restore Elasticsearch Indices

As written previously before how to backup the Kibana index, there is more to the snapshot and restore API. A pretty cool feature is the backup capability to Amazon S3 or a Hadoop FS. Furthermore you need to install respective plugins for that. This post demonstrates only a snapshot on a shared filesystem which doesn’t require a plugin. Some commands that were useful during my cluster upgrade.

Define a snapshot destination

PUT _snapshot/nas
{
  "type": "fs",
    "settings": {
      "compress": "true",
      "location": "/var/opt/elasticsearch/repo/prod"
    }
}

List all snapshot destinations

GET _snapshot/_all

You might see something like this

{
  "nas": {
    "type": "fs",
    "settings": {
      "compress": "true",
      "location": "/var/opt/elasticsearch/repo/prod"
    }
  }
}

Do a snapshot for Kibana

PUT _snapshot/nas/upgrade_512
{
  "indices": ".kibana",
  "ignore_unavailable": "true",
  "include_global_state": false
}

Query all existing snapshot on this snapshot point, pay attention to the state. If it isn’t SUCCESS you better ensure or investigate the backup problem.

GET _snapshot/nas/_all

{
  "snapshots": [
    {
      "snapshot": "upgrade_512",
      "uuid": "ruBTqGRHQMuyokU3OovSiw",
      "version_id": 5010299,
      "version": "5.1.2",
      "indices": [
        ".kibana"
      ],
      "state": "SUCCESS",
      "start_time": "2017-01-15T08:04:54.216Z",
      "start_time_in_millis": 1484467494216,
      "end_time": "2017-01-15T08:04:54.528Z",
      "end_time_in_millis": 1484467494528,
      "duration_in_millis": 312,
      "failures": [],
      "shards": {
        "total": 1,
        "failed": 0,
        "successful": 1
      }
    },
    {
      "snapshot": "snapshot_7",
      "uuid": "7ZdZOvTlQ2SrdjjbgcjqSw",
      "version_id": 5010299,
      "version": "5.1.2",
      "indices": [
        ".kibana"
      ],
      "state": "SUCCESS",
      "start_time": "2017-01-15T08:08:41.391Z",
      "start_time_in_millis": 1484467721391,
      "end_time": "2017-01-15T08:08:41.918Z",
      "end_time_in_millis": 1484467721918,
      "duration_in_millis": 527,
      "failures": [],
      "shards": {
        "total": 1,
        "failed": 0,
        "successful": 1
      }
    }
  ]
}

If you want to restore the index, you may have to close it before and then use the restore action.