Snapshots

class elasticsearch.client.SnapshotClient(client)
Parameters:

client (BaseClient) –

cleanup_repository(*, name, error_trace=None, filter_path=None, human=None, master_timeout=None, pretty=None, timeout=None)

Removes stale data from repository.

https://www.elastic.co/guide/en/elasticsearch/reference/8.13/clean-up-snapshot-repo-api.html

Parameters:
  • name (str) – Snapshot repository to clean up.

  • master_timeout (Literal[-1] | ~typing.Literal[0] | str | None) – Period to wait for a connection to the master node.

  • timeout (Literal[-1] | ~typing.Literal[0] | str | None) – Period to wait for a response.

  • error_trace (bool | None) –

  • filter_path (str | Sequence[str] | None) –

  • human (bool | None) –

  • pretty (bool | None) –

Return type:

ObjectApiResponse[Any]

clone(*, repository, snapshot, target_snapshot, indices=None, error_trace=None, filter_path=None, human=None, master_timeout=None, pretty=None, timeout=None, body=None)

Clones indices from one snapshot into another snapshot in the same repository.

https://www.elastic.co/guide/en/elasticsearch/reference/8.13/modules-snapshots.html

Parameters:
  • repository (str) – A repository name

  • snapshot (str) – The name of the snapshot to clone from

  • target_snapshot (str) – The name of the cloned snapshot to create

  • indices (str | None) –

  • master_timeout (Literal[-1] | ~typing.Literal[0] | str | None) – Explicit operation timeout for connection to master node

  • timeout (Literal[-1] | ~typing.Literal[0] | str | None) –

  • error_trace (bool | None) –

  • filter_path (str | Sequence[str] | None) –

  • human (bool | None) –

  • pretty (bool | None) –

  • body (Dict[str, Any] | None) –

Return type:

ObjectApiResponse[Any]

create(*, repository, snapshot, error_trace=None, feature_states=None, filter_path=None, human=None, ignore_unavailable=None, include_global_state=None, indices=None, master_timeout=None, metadata=None, partial=None, pretty=None, wait_for_completion=None, body=None)

Creates a snapshot in a repository.

https://www.elastic.co/guide/en/elasticsearch/reference/8.13/modules-snapshots.html

Parameters:
  • repository (str) – Repository for the snapshot.

  • snapshot (str) – Name of the snapshot. Must be unique in the repository.

  • feature_states (Sequence[str] | None) – 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_state is true, all current feature states are included by default. If include_global_state is false, no feature states are included by default.

  • ignore_unavailable (bool | None) – If true, the request ignores data streams and indices in indices that are missing or closed. If false, the request returns an error for any data stream or index that is missing or closed.

  • include_global_state (bool | 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 via feature_states).

  • indices (str | Sequence[str] | None) – Data streams and indices to include in the snapshot. Supports multi-target syntax. Includes all data streams and indices by default.

  • master_timeout (Literal[-1] | ~typing.Literal[0] | str | None) – 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.

  • metadata (Mapping[str, Any] | None) – Optional metadata for the snapshot. May have any contents. Must be less than 1024 bytes. This map is not automatically generated by Elasticsearch.

  • partial (bool | None) – 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. If false, the entire restore operation will fail if one or more indices included in the snapshot do not have all primary shards available.

  • wait_for_completion (bool | None) – If true, the request returns a response when the snapshot is complete. If false, the request returns a response when the snapshot initializes.

  • error_trace (bool | None) –

  • filter_path (str | Sequence[str] | None) –

  • human (bool | None) –

  • pretty (bool | None) –

  • body (Dict[str, Any] | None) –

Return type:

ObjectApiResponse[Any]

create_repository(*, name, repository=None, body=None, error_trace=None, filter_path=None, human=None, master_timeout=None, pretty=None, timeout=None, verify=None)

Creates a repository.

https://www.elastic.co/guide/en/elasticsearch/reference/8.13/modules-snapshots.html

Parameters:
  • name (str) – A repository name

  • repository (Mapping[str, Any] | None) –

  • master_timeout (Literal[-1] | ~typing.Literal[0] | str | None) – Explicit operation timeout for connection to master node

  • timeout (Literal[-1] | ~typing.Literal[0] | str | None) – Explicit operation timeout

  • verify (bool | None) – Whether to verify the repository after creation

  • body (Mapping[str, Any] | None) –

  • error_trace (bool | None) –

  • filter_path (str | Sequence[str] | None) –

  • human (bool | None) –

  • pretty (bool | None) –

Return type:

ObjectApiResponse[Any]

delete(*, repository, snapshot, error_trace=None, filter_path=None, human=None, master_timeout=None, pretty=None)

Deletes one or more snapshots.

https://www.elastic.co/guide/en/elasticsearch/reference/8.13/modules-snapshots.html

Parameters:
  • repository (str) – A repository name

  • snapshot (str) – A comma-separated list of snapshot names

  • master_timeout (Literal[-1] | ~typing.Literal[0] | str | None) – Explicit operation timeout for connection to master node

  • error_trace (bool | None) –

  • filter_path (str | Sequence[str] | None) –

  • human (bool | None) –

  • pretty (bool | None) –

Return type:

ObjectApiResponse[Any]

delete_repository(*, name, error_trace=None, filter_path=None, human=None, master_timeout=None, pretty=None, timeout=None)

Deletes a repository.

https://www.elastic.co/guide/en/elasticsearch/reference/8.13/modules-snapshots.html

Parameters:
  • name (str | Sequence[str]) – Name of the snapshot repository to unregister. Wildcard (*) patterns are supported.

  • master_timeout (Literal[-1] | ~typing.Literal[0] | str | None) – Explicit operation timeout for connection to master node

  • timeout (Literal[-1] | ~typing.Literal[0] | str | None) – Explicit operation timeout

  • error_trace (bool | None) –

  • filter_path (str | Sequence[str] | None) –

  • human (bool | None) –

  • pretty (bool | None) –

Return type:

ObjectApiResponse[Any]

get(*, repository, snapshot, after=None, error_trace=None, filter_path=None, from_sort_value=None, human=None, ignore_unavailable=None, include_repository=None, index_details=None, index_names=None, master_timeout=None, offset=None, order=None, pretty=None, size=None, slm_policy_filter=None, sort=None, verbose=None)

Returns information about a snapshot.

https://www.elastic.co/guide/en/elasticsearch/reference/8.13/modules-snapshots.html

Parameters:
  • repository (str) – Comma-separated list of snapshot repository names used to limit the request. Wildcard (*) expressions are supported.

  • snapshot (str | Sequence[str]) – 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.

  • after (str | None) – Offset identifier to start pagination from as returned by the next field in the response body.

  • from_sort_value (str | None) – Value of the current sort column at which to start retrieval. Can either be a string snapshot- or repository name when sorting by snapshot or repository name, a millisecond time value or a number when sorting by index- or shard count.

  • ignore_unavailable (bool | None) – If false, the request returns an error for any snapshots that are unavailable.

  • include_repository (bool | None) – If true, returns the repository name in each snapshot.

  • index_details (bool | None) – 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.

  • index_names (bool | None) – If true, returns the name of each index in each snapshot.

  • master_timeout (Literal[-1] | ~typing.Literal[0] | str | None) – 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.

  • offset (int | None) – Numeric offset to start pagination from based on the snapshots matching this request. Using a non-zero value for this parameter is mutually exclusive with using the after parameter. Defaults to 0.

  • order (Literal['asc', 'desc'] | str | None) – Sort order. Valid values are asc for ascending and desc for descending order. Defaults to asc, meaning ascending order.

  • size (int | None) – Maximum number of snapshots to return. Defaults to 0 which means return all that match the request without limit.

  • slm_policy_filter (str | None) – Filter snapshots by a comma-separated list of SLM policy names that snapshots belong to. Also accepts wildcards (*) and combinations of wildcards followed by exclude patterns starting with -. To include snapshots not created by an SLM policy you can use the special pattern _none that will match all snapshots without an SLM policy.

  • sort (Literal['duration', 'failed_shard_count', 'index_count', 'name', 'repository', 'shard_count', 'start_time'] | str | None) – Allows setting a sort order for the result. Defaults to start_time, i.e. sorting by snapshot start time stamp.

  • verbose (bool | None) – 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.

  • error_trace (bool | None) –

  • filter_path (str | Sequence[str] | None) –

  • human (bool | None) –

  • pretty (bool | None) –

Return type:

ObjectApiResponse[Any]

get_repository(*, name=None, error_trace=None, filter_path=None, human=None, local=None, master_timeout=None, pretty=None)

Returns information about a repository.

https://www.elastic.co/guide/en/elasticsearch/reference/8.13/modules-snapshots.html

Parameters:
  • name (str | Sequence[str] | None) – A comma-separated list of repository names

  • local (bool | None) – Return local information, do not retrieve the state from master node (default: false)

  • master_timeout (Literal[-1] | ~typing.Literal[0] | str | None) – Explicit operation timeout for connection to master node

  • error_trace (bool | None) –

  • filter_path (str | Sequence[str] | None) –

  • human (bool | None) –

  • pretty (bool | None) –

Return type:

ObjectApiResponse[Any]

restore(*, repository, snapshot, error_trace=None, feature_states=None, filter_path=None, human=None, ignore_index_settings=None, ignore_unavailable=None, include_aliases=None, include_global_state=None, index_settings=None, indices=None, master_timeout=None, partial=None, pretty=None, rename_pattern=None, rename_replacement=None, wait_for_completion=None, body=None)

Restores a snapshot.

https://www.elastic.co/guide/en/elasticsearch/reference/8.13/modules-snapshots.html

Parameters:
  • repository (str) – A repository name

  • snapshot (str) – A snapshot name

  • feature_states (Sequence[str] | None) –

  • ignore_index_settings (Sequence[str] | None) –

  • ignore_unavailable (bool | None) –

  • include_aliases (bool | None) –

  • include_global_state (bool | None) –

  • index_settings (Mapping[str, Any] | None) –

  • indices (str | Sequence[str] | None) –

  • master_timeout (Literal[-1] | ~typing.Literal[0] | str | None) – Explicit operation timeout for connection to master node

  • partial (bool | None) –

  • rename_pattern (str | None) –

  • rename_replacement (str | None) –

  • wait_for_completion (bool | None) – Should this request wait until the operation has completed before returning

  • error_trace (bool | None) –

  • filter_path (str | Sequence[str] | None) –

  • human (bool | None) –

  • pretty (bool | None) –

  • body (Dict[str, Any] | None) –

Return type:

ObjectApiResponse[Any]

status(*, repository=None, snapshot=None, error_trace=None, filter_path=None, human=None, ignore_unavailable=None, master_timeout=None, pretty=None)

Returns information about the status of a snapshot.

https://www.elastic.co/guide/en/elasticsearch/reference/8.13/modules-snapshots.html

Parameters:
  • repository (str | None) – A repository name

  • snapshot (str | Sequence[str] | None) – A comma-separated list of snapshot names

  • ignore_unavailable (bool | None) – Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown

  • master_timeout (Literal[-1] | ~typing.Literal[0] | str | None) – Explicit operation timeout for connection to master node

  • error_trace (bool | None) –

  • filter_path (str | Sequence[str] | None) –

  • human (bool | None) –

  • pretty (bool | None) –

Return type:

ObjectApiResponse[Any]

verify_repository(*, name, error_trace=None, filter_path=None, human=None, master_timeout=None, pretty=None, timeout=None)

Verifies a repository.

https://www.elastic.co/guide/en/elasticsearch/reference/8.13/modules-snapshots.html

Parameters:
  • name (str) – A repository name

  • master_timeout (Literal[-1] | ~typing.Literal[0] | str | None) – Explicit operation timeout for connection to master node

  • timeout (Literal[-1] | ~typing.Literal[0] | str | None) – Explicit operation timeout

  • error_trace (bool | None) –

  • filter_path (str | Sequence[str] | None) –

  • human (bool | None) –

  • pretty (bool | None) –

Return type:

ObjectApiResponse[Any]