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.
manageThe name of the repository to restore a snapshot from.
The name of the snapshot to restore.
The period to wait for the master node.
If the master node is not available before the timeout expires, the request fails and returns an error.
To indicate that the request should never timeout, set it to -1.
If true, the request returns a response when the restore operation completes.
The operation is complete when it finishes all attempts to recover primary shards for restored indices.
This applies even if one or more of the recovery attempts fail.
If false, the request returns a response when the restore operation initializes.
The feature states to restore.
If include_global_state is true, the request restores all feature states in the snapshot by default.
If include_global_state is false, the request restores no feature states by default.
Note that specifying an empty array will result in the default behavior.
To restore no feature states, regardless of the include_global_state value, specify an array containing only the value none (["none"]).
The index settings to not restore from the snapshot.
You can't use this option to ignore index.number_of_shards.
For data streams, this option applies only to restored backing indices. New backing indices are configured using the data stream's matching index template.
If true, the request restores aliases for any restored data streams and indices.
If false, the request doesn’t restore aliases.
Default value is true.
If true, restore the cluster state. The cluster state includes:
If include_global_state is true, the restore operation merges the legacy index templates in your cluster with the templates contained in the snapshot, replacing any existing ones whose name matches one in the snapshot.
It completely removes all persistent settings, non-legacy index templates, ingest pipelines, and ILM lifecycle policies that exist in your cluster and replaces them with the corresponding items from the snapshot.
Use the feature_states parameter to configure how feature states are restored.
If include_global_state is true and a snapshot was created without a global state then the restore request will fail.
Default value is false.
Index settings to add or change in restored indices, including backing indices.
You can't use this option to change index.number_of_shards.
For data streams, this option applies only to restored backing indices. New backing indices are configured using the data stream's matching index template.
A comma-separated list of indices and data streams to restore. It supports a multi-target syntax. The default behavior is all regular indices and regular data streams in the snapshot.
You can't use this parameter to restore system indices or system data streams.
Use feature_states instead.
If false, the entire restore operation will fail if one or more indices included in the snapshot do not have all primary shards available.
If true, it 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.
Default value is false.
A rename pattern to apply to restored data streams and indices.
Data streams and 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 rename replacement string that is used with the rename_pattern.
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)
);
{
"indices": "index_1,index_2",
"ignore_unavailable": true,
"include_global_state": false,
"rename_pattern": "index_(.+)",
"rename_replacement": "restored_index_$1",
"include_aliases": false
}
{
"indices": "index_1"
}