Restore snapshot APIedit

Restores a snapshot of a cluster or specified indices.

POST /_snapshot/my_repository/my_snapshot/_restore

Requestedit

POST /_snapshot/<repository>/<snapshot>/_restore

Descriptionedit

Use the restore snapshot API to restore a snapshot of a cluster, including all indices in the snapshot. If you do not want to restore the entire snapshot, you can select specific indices to restore.

You can run the restore operation on a cluster that contains an elected master node and has data nodes with enough capacity to accommodate the snapshot you are restoring. Existing indices can only be restored if they are closed and have the same number of shards as the indices in the snapshot. The restore operation automatically opens restored indices if they were closed and creates new indices if they do not exist in the cluster.

Path parametersedit

<repository>
(Required, string) Name of the repository to restore a snapshot from.
<snapshot>
(Required, string) Name of the snapshot to restore.

Request bodyedit

ignore_unavailable

(Optional, boolean) If false, the request returns an error for any data stream or index that is missing or closed. Defaults to false.

If true, the request ignores data streams and indices in indices that are missing or closed.

ignore_index_settings
(Optional, string) A comma-separated list of index settings that should not be restored from a snapshot.
include_aliases

(Optional, boolean) If true, index aliases from the original snapshot are restored. Defaults to true.

If false, prevents aliases from being restored together with associated indices.

include_global_state

(Optional, boolean) If false, the cluster state is not restored. Defaults to false.

If true, the current cluster state is included in the restore operation.

The cluster state includes:

  • Persistent cluster settings
  • Index templates
  • Legacy index templates
  • Ingest pipelines
  • ILM lifecycle policies

By default, the entire restore operation will fail if one or more indices included in the snapshot do not have all primary shards available. You can change this behavior by setting partial to true.

index_settings

(Optional, string) A comma-separated list of settings to add or change in all restored indices. Use this parameter to override index settings when restoring snapshots.

For more information regarding all the different index-level settings that you can specify, see index modules.

indices

(Optional, string) A comma-separated list of indices to restore from the snapshot. Multi-index syntax is supported.

By default, a restore operation includes all indices in the snapshot. If this argument is provided, the restore operation only includes the specified indices.

partial

(Optional, boolean) If false, the entire restore operation will fail if one or more indices included in the snapshot do not have all primary shards available. Defaults to false.

If true, allows restoring a partial snapshot of indices with unavailable shards. Only shards that were successfully included in the snapshot will be restored. All missing shards will be recreated as empty.

rename_pattern

(Optional, string) Defines a rename pattern to apply to restored indices. Indices matching the rename pattern will be renamed according to rename_replacement.

The rename pattern is applied as defined by the regular expression that supports referencing the original text, according to the appendReplacement logic.

The request will fail if two or more indices will be renamed into the same name.

rename_replacement
(Optional, string) Defines the rename replacement string. See rename_pattern for more information.
wait_for_completion

(Optional, boolean) If false, the request returns a response when the restore operation initializes. Defaults to false.

If true, the request returns a response when the restore operation completes.

Examplesedit

The following request 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 when restored.

For example, index_1 will be renamed to restored_index_1. index_2 will be renamed to restored_index_2.

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
}

The API returns an acknowledgement if the request succeeds. If the request encounters errors, the response indicates any issues found, such as open indices that are blocking the restore operation from completing.