Create a snapshot Generally available; Added in 0.0.0

POST /_snapshot/{repository}/{snapshot}

Take a snapshot of a cluster or of data streams and indices.

Required authorization

  • Cluster privileges: create_snapshot
External documentation

Path parameters

  • repository string Required

    Repository for the snapshot.

  • snapshot string Required

    Name of the snapshot. Must be unique in the repository.

Query parameters

  • master_timeout string

    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.

    Values are -1 or 0.

  • wait_for_completion boolean

    If true, the request returns a response when the snapshot is complete. If false, the request returns a response when the snapshot initializes.

application/json

Body

  • ignore_unavailable boolean

    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 boolean

    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 string | array[string]
  • feature_states array[string]

    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.

  • metadata object
    Hide metadata attribute Show metadata attribute object
    • * object Additional properties
  • partial boolean

    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.

Responses

  • 200 application/json
    Hide response attributes Show response attributes object
    • accepted boolean Generally available; Added in 7.15.0

      Equals true if the snapshot was accepted. Present when the request had wait_for_completion set to false

    • snapshot object
      Hide snapshot attributes Show snapshot attributes object
      • data_streams array[string] Required
      • duration string

        A duration. Units can be nanos, micros, ms (milliseconds), s (seconds), m (minutes), h (hours) and d (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.

      • duration_in_millis number

        Time unit for milliseconds

      • end_time string | number

        A date and time, either as a string whose format can depend on the context (defaulting to ISO 8601), or a number of milliseconds since the Epoch. Elasticsearch accepts both as input, but will generally output a string representation.

        One of:

        Time unit for milliseconds

      • end_time_in_millis number

        Time unit for milliseconds

      • failures array[object]
        Hide failures attributes Show failures attributes object
        • index string Required
        • node_id string
        • reason string Required
        • shard_id number Required
        • index_uuid string Required
        • status string Required
      • include_global_state boolean
      • indices array[string]
      • index_details object Generally available; Added in 7.13.0
        Hide index_details attribute Show index_details attribute object
        • * object Additional properties
          Hide * attributes Show * attributes object
      • metadata object
        Hide metadata attribute Show metadata attribute object
        • * object Additional properties
      • reason string
      • repository string
      • snapshot string Required
      • shards object
        Hide shards attributes Show shards attributes object
        • failed number Required
        • successful number Required
        • total number Required
        • failures array[object]
          Hide failures attributes Show failures attributes object
          • index string
          • node string
          • reason object Required

            Cause and details about a request failure. This class defines the properties common to all error types. Additional details are also provided, that depend on the error type.

            Hide reason attributes Show reason attributes object
            • type string Required

              The type of error

            • reason
            • stack_trace string

              The server stack trace. Present only if the error_trace=true parameter was sent with the request.

            • caused_by object

              Cause and details about a request failure. This class defines the properties common to all error types. Additional details are also provided, that depend on the error type.

            • root_cause array[object]
            • suppressed array[object]
          • shard number Required
          • status string
        • skipped number
      • start_time string | number

        A date and time, either as a string whose format can depend on the context (defaulting to ISO 8601), or a number of milliseconds since the Epoch. Elasticsearch accepts both as input, but will generally output a string representation.

        One of:

        Time unit for milliseconds

      • start_time_in_millis number

        Time unit for milliseconds

      • state string
      • uuid string Required
      • version string
      • version_id number
      • feature_states array[object]
        Hide feature_states attributes Show feature_states attributes object
        • feature_name string Required
        • indices string | array[string] Required
POST /_snapshot/{repository}/{snapshot}
curl \
 --request POST 'http://api.example.com/_snapshot/{repository}/{snapshot}' \
 --header "Authorization: $API_KEY" \
 --header "Content-Type: application/json" \
 --data '"{\n  \"indices\": \"index_1,index_2\",\n  \"ignore_unavailable\": true,\n  \"include_global_state\": false,\n  \"metadata\": {\n    \"taken_by\": \"user123\",\n    \"taken_because\": \"backup before upgrading\"\n  }\n}"'
Request example
Run `PUT /_snapshot/my_repository/snapshot_2?wait_for_completion=true` to take a snapshot of `index_1` and `index_2`.
{
  "indices": "index_1,index_2",
  "ignore_unavailable": true,
  "include_global_state": false,
  "metadata": {
    "taken_by": "user123",
    "taken_because": "backup before upgrading"
  }
}
Response examples (200)
A successful response from `PUT /_snapshot/my_repository/snapshot_2?wait_for_completion=true`.
{
  "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
    }
  }
}