All methods and paths for this operation:
Take a snapshot of a cluster or of data streams and indices.
Required authorization
- Cluster privileges:
create_snapshot
Path parameters
-
The name of the repository for the snapshot.
-
The name of the snapshot. It supportes date math. It must be unique in the repository.
Query parameters
-
The period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error.
External documentation -
If
true, the request returns a response when the snapshot is complete. Iffalse, the request returns a response when the snapshot initializes.
Body
-
Determines how wildcard patterns in the
indicesparameter match data streams and indices. It supports comma-separated values such asopen,hidden.Supported values include:
all: Match any data stream or index, including hidden ones.open: Match open, non-hidden indices. Also matches any non-hidden data stream.closed: Match closed, non-hidden indices. Also matches any non-hidden data stream. Data streams cannot be closed.hidden: Match hidden data streams and hidden indices. Must be combined withopen,closed, orboth.none: Wildcard expressions are not accepted.
-
The feature states to include in the snapshot. Each feature state includes one or more system indices containing related data. You can view a list of eligible features using the get features API.
If
include_global_stateistrue, all current feature states are included by default. Ifinclude_global_stateisfalse, no feature states are included by default.Note that specifying an empty array will result in the default behavior. To exclude all feature states, regardless of the
include_global_statevalue, specify an array with only the valuenone(["none"]). -
If
true, the current cluster state is included in the snapshot. The cluster state includes persistent cluster settings, composable index templates, legacy index templates, ingest pipelines, and ILM policies. It also includes data stored in system indices, such as Watches and task records (configurable viafeature_states).Default value is
true. -
A comma-separated list of data streams and indices to include in the snapshot. It supports a multi-target syntax. The default is an empty array (
[]), which includes all regular data streams and regular indices. To exclude all data streams and indices, use-*.You can't use this parameter to include or exclude system indices or system data streams from a snapshot. Use
feature_statesinstead. -
Arbitrary metadata to the snapshot, such as a record of who took the snapshot, why it was taken, or any other useful data. It can have any contents but it must be less than 1024 bytes. This information is not automatically generated by Elasticsearch.
-
If
true, allows the snapshot to proceed even if some of the target shards are unavailable. In this case, the resulting snapshot will not contain snapshots of the unavailable target shards, and will report its state asPARTIAL. Additionally, iftrue, allows index metadata operations such as deletions while the snapshot is in progress. This is almost always preferable to failing the snapshot completely when a single shard is unavailable, and blocking index metadata operations.If
false, the entire restore operation will fail if one or more indices included in the snapshot do not have all primary shards available, and index metadata operations such as deletions will be forbidden until the snapshot completes.Default value is
false.
PUT /_snapshot/my_repository/snapshot_2?wait_for_completion=true
{
"partial": true,
"indices": "index_1,index_2",
"ignore_unavailable": true,
"include_global_state": false,
"metadata": {
"taken_by": "user123",
"taken_because": "backup before upgrading"
}
}
resp = client.snapshot.create(
repository="my_repository",
snapshot="snapshot_2",
wait_for_completion=True,
partial=True,
indices="index_1,index_2",
ignore_unavailable=True,
include_global_state=False,
metadata={
"taken_by": "user123",
"taken_because": "backup before upgrading"
},
)
const response = await client.snapshot.create({
repository: "my_repository",
snapshot: "snapshot_2",
wait_for_completion: "true",
partial: true,
indices: "index_1,index_2",
ignore_unavailable: true,
include_global_state: false,
metadata: {
taken_by: "user123",
taken_because: "backup before upgrading",
},
});
response = client.snapshot.create(
repository: "my_repository",
snapshot: "snapshot_2",
wait_for_completion: "true",
body: {
"partial": true,
"indices": "index_1,index_2",
"ignore_unavailable": true,
"include_global_state": false,
"metadata": {
"taken_by": "user123",
"taken_because": "backup before upgrading"
}
}
)
$resp = $client->snapshot()->create([
"repository" => "my_repository",
"snapshot" => "snapshot_2",
"wait_for_completion" => "true",
"body" => [
"partial" => true,
"indices" => "index_1,index_2",
"ignore_unavailable" => true,
"include_global_state" => false,
"metadata" => [
"taken_by" => "user123",
"taken_because" => "backup before upgrading",
],
],
]);
curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d '{"partial":true,"indices":"index_1,index_2","ignore_unavailable":true,"include_global_state":false,"metadata":{"taken_by":"user123","taken_because":"backup before upgrading"}}' "$ELASTICSEARCH_URL/_snapshot/my_repository/snapshot_2?wait_for_completion=true"
client.snapshot().create(c -> c
.ignoreUnavailable(true)
.includeGlobalState(false)
.indices("index_1,index_2")
.metadata(Map.of("taken_by", JsonData.fromJson("\"user123\""),"taken_because", JsonData.fromJson("\"backup before upgrading\"")))
.repository("my_repository")
.snapshot("snapshot_2")
.waitForCompletion(true)
);
{
"partial": true,
"indices": "index_1,index_2",
"ignore_unavailable": true,
"include_global_state": false,
"metadata": {
"taken_by": "user123",
"taken_because": "backup before upgrading"
}
}
{
"snapshot": {
"snapshot": "snapshot_2",
"uuid": "vdRctLCxSketdKb54xw67g",
"repository": "my_repository",
"version_id": <version_id>,
"version": <version>,
"indices": [],
"data_streams": [],
"feature_states": [],
"include_global_state": false,
"metadata": {
"taken_by": "user123",
"taken_because": "backup before upgrading"
},
"state": "SUCCESS",
"start_time": "2020-06-25T14:00:28.850Z",
"start_time_in_millis": 1593093628850,
"end_time": "2020-06-25T14:00:28.850Z",
"end_time_in_millis": 1593094752018,
"duration_in_millis": 0,
"failures": [],
"shards": {
"total": 0,
"failed": 0,
"successful": 0
}
}
}