Restore a snapshot Generally available; Added in 0.0.0

POST /_snapshot/{repository}/{snapshot}/_restore

Restore a snapshot of a cluster or data streams and indices.

You can restore a snapshot only to a running cluster with an elected master node. The snapshot repository must be registered and available to the cluster. The snapshot and cluster versions must be compatible.

To restore a snapshot, the cluster's global metadata must be writable. Ensure there are't any cluster blocks that prevent writes. The restore operation ignores index blocks.

Before you restore a data stream, ensure the cluster contains a matching index template with data streams enabled. To check, use the index management feature in Kibana or the get index template API:

GET _index_template/*?filter_path=index_templates.name,index_templates.index_template.index_patterns,index_templates.index_template.data_stream

If no such template exists, you can create one or restore a cluster state that contains one. Without a matching index template, a data stream can't roll over or create backing indices.

If your snapshot contains data from App Search or Workplace Search, you must restore the Enterprise Search encryption key before you restore the snapshot.

Required authorization

  • Cluster privileges: manage
External documentation

Path parameters

  • repository string Required

    A repository name

  • snapshot string Required

    A snapshot name

Query parameters

  • master_timeout string

    Explicit operation timeout for connection to master node

    Values are -1 or 0.

  • wait_for_completion boolean

    Should this request wait until the operation has completed before returning

application/json

Body

  • feature_states array[string]
  • ignore_index_settings array[string]
  • ignore_unavailable boolean
  • include_aliases boolean
  • include_global_state boolean
  • index_settings object
    Index settings
  • indices string | array[string]
  • partial boolean
  • rename_pattern string
  • rename_replacement string

Responses

  • 200 application/json
    Hide response attributes Show response attributes object
    • accepted boolean
    • snapshot object
      Hide snapshot attributes Show snapshot attributes object
      • indices array[string] Required
      • snapshot string Required
      • shards object Required
        Hide shards attributes Show shards attributes object
        • failed number Required
        • successful number Required
        • total number Required
        • failures array[object]
          Hide failures attributes Show failures attributes object
          • index string
          • node string
          • reason object Required

            Cause and details about a request failure. This class defines the properties common to all error types. Additional details are also provided, that depend on the error type.

            Hide reason attributes Show reason attributes object
            • type string Required

              The type of error

            • reason
            • stack_trace string

              The server stack trace. Present only if the error_trace=true parameter was sent with the request.

            • caused_by object

              Cause and details about a request failure. This class defines the properties common to all error types. Additional details are also provided, that depend on the error type.

            • root_cause array[object]
            • suppressed array[object]
          • shard number Required
          • status string
        • skipped number
POST /_snapshot/{repository}/{snapshot}/_restore
POST /_snapshot/my_repository/snapshot_2/_restore?wait_for_completion=true
{
  "indices": "index_1,index_2",
  "ignore_unavailable": true,
  "include_global_state": false,
  "rename_pattern": "index_(.+)",
  "rename_replacement": "restored_index_$1",
  "include_aliases": false
}
resp = client.snapshot.restore(
    repository="my_repository",
    snapshot="snapshot_2",
    wait_for_completion=True,
    indices="index_1,index_2",
    ignore_unavailable=True,
    include_global_state=False,
    rename_pattern="index_(.+)",
    rename_replacement="restored_index_$1",
    include_aliases=False,
)
const response = await client.snapshot.restore({
  repository: "my_repository",
  snapshot: "snapshot_2",
  wait_for_completion: "true",
  indices: "index_1,index_2",
  ignore_unavailable: true,
  include_global_state: false,
  rename_pattern: "index_(.+)",
  rename_replacement: "restored_index_$1",
  include_aliases: false,
});
response = client.snapshot.restore(
  repository: "my_repository",
  snapshot: "snapshot_2",
  wait_for_completion: "true",
  body: {
    "indices": "index_1,index_2",
    "ignore_unavailable": true,
    "include_global_state": false,
    "rename_pattern": "index_(.+)",
    "rename_replacement": "restored_index_$1",
    "include_aliases": false
  }
)
$resp = $client->snapshot()->restore([
    "repository" => "my_repository",
    "snapshot" => "snapshot_2",
    "wait_for_completion" => "true",
    "body" => [
        "indices" => "index_1,index_2",
        "ignore_unavailable" => true,
        "include_global_state" => false,
        "rename_pattern" => "index_(.+)",
        "rename_replacement" => "restored_index_$1",
        "include_aliases" => false,
    ],
]);
curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d '{"indices":"index_1,index_2","ignore_unavailable":true,"include_global_state":false,"rename_pattern":"index_(.+)","rename_replacement":"restored_index_$1","include_aliases":false}' "$ELASTICSEARCH_URL/_snapshot/my_repository/snapshot_2/_restore?wait_for_completion=true"
client.snapshot().restore(r -> r
    .ignoreUnavailable(true)
    .includeAliases(false)
    .includeGlobalState(false)
    .indices("index_1,index_2")
    .renamePattern("index_(.+)")
    .renameReplacement("restored_index_$1")
    .repository("my_repository")
    .snapshot("snapshot_2")
    .waitForCompletion(true)
);
Request examples
Run `POST /_snapshot/my_repository/snapshot_2/_restore?wait_for_completion=true`. It restores `index_1` and `index_2` from `snapshot_2`. The `rename_pattern` and `rename_replacement` parameters indicate any index matching the regular expression `index_(.+)` will be renamed using the pattern `restored_index_$1`. For example, `index_1` will be renamed to `restored_index_1`.
{
  "indices": "index_1,index_2",
  "ignore_unavailable": true,
  "include_global_state": false,
  "rename_pattern": "index_(.+)",
  "rename_replacement": "restored_index_$1",
  "include_aliases": false
}
Close `index_1` then run `POST /_snapshot/my_repository/snapshot_2/_restore?wait_for_completion=true` to restore an index in-place. For example, you might want to perform this type of restore operation when no alternative options surface after the cluster allocation explain API reports `no_valid_shard_copy`.
{
  "indices": "index_1"
}