Get snapshot API

edit

Retrieves information about one or more snapshots.

GET /_snapshot/my_repository/my_snapshot

Request

edit

GET /_snapshot/<repository>/<snapshot>

Prerequisites

edit
  • If the Elasticsearch security features are enabled, you must have the monitor_snapshot, create_snapshot, or manage cluster privilege to use this API.

Description

edit

Use the get snapshot API to return information about one or more snapshots, including:

  • Start and end time values
  • Version of Elasticsearch that created the snapshot
  • List of included indices
  • Current state of the snapshot
  • List of failures that occurred during the snapshot

Path parameters

edit
<repository>

(Required, string) Comma-separated list of snapshot repository names used to limit the request. Wildcard (*) expressions are supported.

To get information about all snapshot repositories registered in the cluster, omit this parameter or use * or _all.

<snapshot>

(Required, string) Comma-separated list of snapshot names to retrieve. Also accepts wildcards (*).

  • To get information about all snapshots in a registered repository, use a wildcard (*) or _all.
  • To get information about any snapshots that are currently running, use _current.

    Using _all in a request fails if any snapshots are unavailable. Set ignore_unavailable to true to return only available snapshots.

Query parameters

edit
master_timeout
(Optional, time units) 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. Defaults to 30s.
ignore_unavailable

(Optional, Boolean) If false, the request returns an error for any snapshots that are unavailable. Defaults to false.

If true, the request ignores snapshots that are unavailable, such as those that are corrupted or temporarily cannot be returned.

verbose
(Optional, Boolean) If true, returns additional information about each snapshot such as the version of Elasticsearch which took the snapshot, the start and end times of the snapshot, and the number of shards snapshotted. Defaults to true. If false, omits the additional information.
index_details
(Optional, Boolean) If true, returns additional information about each index in the snapshot comprising the number of shards in the index, the total size of the index in bytes, and the maximum number of segments per shard in the index. Defaults to false, meaning that this information is omitted.
sort

(Optional, string) Allows setting a sort order for the result. Defaults to start_time, i.e. sorting by snapshot start time stamp.

Valid values for sort
start_time
Sort snapshots by their start time stamp and break ties by snapshot name.
duration
Sort snapshots by their duration and break ties by snapshot name.
name
Sort snapshots by their name.
index_count
Sort snapshots by the number of indices they contain and break ties by snapshot name.
size
(Optional, integer) Maximum number of snapshots to return. Defaults to 0 which means return all that match the request without limit.
order
(Optional, string) Sort order. Valid values are asc for ascending and desc for descending order. Defaults to asc, meaning ascending order.
after
(Optional, string) Offset identifier to start pagination from as returned by the next field in the response body.

The after parameter and next field allow for iterating through snapshots with some consistency guarantees regarding concurrent creation or deletion of snapshots. It is guaranteed that any snapshot that exists at the beginning of the iteration and not concurrently deleted will be seen during the iteration. Snapshots concurrently created may be seen during an iteration.

The pagination parameters size, order, after and sort are not supported when using verbose=false and the sort order for requests with verbose=false is undefined.

Response body

edit
snapshot
(string) Name of the snapshot.
uuid
(string) Universally unique identifier (UUID) of the snapshot.
version_id
(int) Build ID of the Elasticsearch version used to create the snapshot.
version
(float) Elasticsearch version used to create the snapshot.
indices
(array) List of indices included in the snapshot.
index_details

(object) Details of each index in the snapshot, keyed by index name. Only present if the ?index_details query parameter is set, and only contains details for indices that were completely snapshotted in a sufficiently recent version of Elasticsearch.

Properties of index_details
shard_count
(integer) Number of shards in this index.
size
(string) Total size of all shards in this index. Only present if the ?human query paramter is set.
size_in_bytes
(long) Total size of all shards in this index, in bytes.
max_segments_per_shard
(integer) Maximum number of segments per shard in this index snapshot.
data_streams
(array) List of data streams included in the snapshot.
include_global_state
(Boolean) Indicates whether the current cluster state is included in the snapshot.
feature_states
(array) List of feature states which were included when the snapshot was taken, including the list of system indices included as part of the feature state. The feature_name field of each can be used in the feature_states parameter when restoring the snapshot to restore a subset of feature states. Only present if the snapshot includes one or more feature states.
start_time
(string) Date timestamp of when the snapshot creation process started.
start_time_in_millis
(long) The time, in milliseconds, when the snapshot creation process started.
end_time
(string) Date timestamp of when the snapshot creation process ended.
end_time_in_millis
(long) The time, in milliseconds, when the snapshot creation process ended.
duration_in_millis
(long) How long, in milliseconds, it took to create the snapshot.
failures
(array) Lists any failures that occurred when creating the snapshot.
shards

(object) Contains a count of shards in the snapshot.

Properties of shards
total
(integer) Total number of shards included in the snapshot.
successful
(integer) Number of shards that were successfully included in the snapshot.
failed
(integer) Number of shards that failed to be included in the snapshot.
state

(string) The snapshot state can be one of the following values:

Values for state
IN_PROGRESS
The snapshot is currently running.
SUCCESS
The snapshot finished and all shards were stored successfully.
FAILED
The snapshot finished with an error and failed to store any data.
PARTIAL
The global cluster state was stored, but data of at least one shard was not stored successfully. The failures section of the response contains more detailed information about shards that were not processed correctly.
next
(string) If the request contained a size limit and there might be more results, a next field will be added to the response and can be used as the after query parameter to fetch additional results.

Examples

edit

The following request returns information for snapshot_2 in the my_repository repository.

GET /_snapshot/my_repository/snapshot_2

The API returns the following response:

{
  "snapshots": [
    {
      "snapshot": "snapshot_2",
      "uuid": "vdRctLCxSketdKb54xw67g",
      "repository": "my_repository",
      "version_id": <version_id>,
      "version": <version>,
      "indices": [],
      "data_streams": [],
      "feature_states": [],
      "include_global_state": true,
      "state": "SUCCESS",
      "start_time": "2020-07-06T21:55:18.129Z",
      "start_time_in_millis": 1593093628850,
      "end_time": "2020-07-06T21:55:18.129Z",
      "end_time_in_millis": 1593094752018,
      "duration_in_millis": 0,
      "failures": [],
      "shards": {
        "total": 0,
        "failed": 0,
        "successful": 0
      }
    }
  ]
}

The following request returns information for all snapshots with prefix snapshot in the my_repository repository, limiting the response size to 2 and sorting by snapshot name.

GET /_snapshot/my_repository/snapshot*?size=2&sort=name

The API returns the following response:

{
  "snapshots": [
    {
      "snapshot": "snapshot_1",
      "uuid": "dKb54xw67gvdRctLCxSket",
      "repository": "my_repository",
      "version_id": <version_id>,
      "version": <version>,
      "indices": [],
      "data_streams": [],
      "feature_states": [],
      "include_global_state": true,
      "state": "SUCCESS",
      "start_time": "2020-07-06T21:55:18.129Z",
      "start_time_in_millis": 1593093628850,
      "end_time": "2020-07-06T21:55:18.129Z",
      "end_time_in_millis": 1593094752018,
      "duration_in_millis": 0,
      "failures": [],
      "shards": {
        "total": 0,
        "failed": 0,
        "successful": 0
      }
    },
    {
      "snapshot": "snapshot_2",
      "uuid": "vdRctLCxSketdKb54xw67g",
      "repository": "my_repository",
      "version_id": <version_id>,
      "version": <version>,
      "indices": [],
      "data_streams": [],
      "feature_states": [],
      "include_global_state": true,
      "state": "SUCCESS",
      "start_time": "2020-07-06T21:55:18.130Z",
      "start_time_in_millis": 1593093628851,
      "end_time": "2020-07-06T21:55:18.130Z",
      "end_time_in_millis": 1593094752019,
      "duration_in_millis": 1,
      "failures": [],
      "shards": {
        "total": 0,
        "failed": 0,
        "successful": 0
      }
    }
  ],
  "next": "c25hcHNob3RfMixteV9yZXBvc2l0b3J5LHNuYXBzaG90XzI="
}

A subsequent request for the remaining snapshots can then be made using the next value from the previous response as after parameter.

GET /_snapshot/my_repository/snapshot*?size=2&sort=name&after=c25hcHNob3RfMixteV9yZXBvc2l0b3J5LHNuYXBzaG90XzI=

The API returns the following response:

{
  "snapshots": [
    {
      "snapshot": "snapshot_3",
      "uuid": "dRctdKb54xw67gvLCxSket",
      "repository": "my_repository",
      "version_id": <version_id>,
      "version": <version>,
      "indices": [],
      "data_streams": [],
      "feature_states": [],
      "include_global_state": true,
      "state": "SUCCESS",
      "start_time": "2020-07-06T21:55:18.129Z",
      "start_time_in_millis": 1593093628850,
      "end_time": "2020-07-06T21:55:18.129Z",
      "end_time_in_millis": 1593094752018,
      "duration_in_millis": 0,
      "failures": [],
      "shards": {
        "total": 0,
        "failed": 0,
        "successful": 0
      }
    }
  ]
}