diff --git a/_api-reference/search-template.md b/_api-reference/search-template.md index 3dcaf3f5987..ba762ff3154 100644 --- a/_api-reference/search-template.md +++ b/_api-reference/search-template.md @@ -1,7 +1,7 @@ --- layout: default title: Search templates -nav_order: 80 +nav_order: 79 redirect_from: - /opensearch/search-template/ - /search-plugins/search-template/ diff --git a/_api-reference/snapshot-management-apis/create-policy.md b/_api-reference/snapshot-management-apis/create-policy.md new file mode 100644 index 00000000000..e2249566469 --- /dev/null +++ b/_api-reference/snapshot-management-apis/create-policy.md @@ -0,0 +1,602 @@ +--- +layout: default +title: Create Snapshot Policy API +parent: Snapshot Management APIs +nav_order: 10 +--- + +# Create Snapshot Policy API +**Introduced 2.4** +{: .label .label-purple } + +The Create Snapshot Policy API allows you to define automated snapshot management policies in OpenSearch. + +Snapshot policies automate backups by scheduling snapshots and managing their lifecycle. Each policy can include the following: + +- A cron-based schedule for snapshot creation. +- Index patterns to include in each snapshot. +- Retention rules based on age or count. +- Deletion schedules for expired snapshots. +- Notification settings for snapshot events. + + + +## Endpoints +```json +POST /_plugins/_sm/policies/{policy_name} +``` + + + +## Path parameters + +The following table lists the available path parameters. + +| Parameter | Required | Data type | Description | +| :--- | :--- | :--- | :--- | +| `policy_name` | **Required** | String | The name of the snapshot management policy to create. | + + + + +## Request body fields + +The request body is optional. It is a JSON object with the following fields: + +| Property | Required | Data type | Description | Default | +| :--- | :--- | :--- | :--- | :--- | +| `creation` | **Required** | Object | Defines when and how often snapshots should be created. | N/A | +| `snapshot_config` | **Required** | Object | Specifies the snapshot settings, including repository settings, indexes to back up, and other snapshot options. | N/A | +| `deletion` | Optional | Object | Configures the automatic cleanup of old snapshots based on age or count conditions. | N/A | +| `description` | Optional | String | A human-readable description of the snapshot policy's purpose. | N/A | +| `enabled` | Optional | Boolean | Whether the policy should start executing upon creation. | `true` | +| `notification` | Optional | Object | Configures when and how to send notifications about snapshot operations. | N/A | + +
+ + Request body fields: creation + + {: .text-delta} + +The configuration for the snapshot creation schedule. + +`creation` is a JSON object with the following fields: + +| Property | Required | Data type | Description | +| :--- | :--- | :--- | :--- | +| `schedule` | **Required** | Object | Defines when snapshots should be created using a cron schedule. | +| `time_limit` | Optional | String | The maximum amount of time for allowed snapshot creation. | + +
+ +
+ + Request body fields: creation > schedule + + {: .text-delta} + +`schedule` is a JSON object with the following fields: + +| Property | Data type | Description | +| :--- | :--- | :--- | +| `cron` | Object | Defines the snapshot schedule using cron expressions. Required for creating periodic snapshots. | + +
+ +
+ + Request body fields: creation > schedule > cron + + {: .text-delta} + +`cron` is a JSON object with the following fields: + +| Property | Required | Data type | Description | +| :--- | :--- | :--- | :--- | +| `expression` | **Required** | String | The standard cron expression that defines when snapshots should be created, such as `0 0 * * *` for daily at midnight. | +| `timezone` | **Required** | String | The time zone used for interpreting the cron expression such as `UTC`, `America/Los_Angeles`. | + +
+ +
+ + Request body fields: deletion + + {: .text-delta} + +The configuration for snapshot deletion rules and schedule. + +`deletion` is a JSON object with the following fields: + +| Property | Data type | Description | +| :--- | :--- | :--- | +| `condition` | Object | Defines the criteria for when snapshots should be deleted. | +| `schedule` | Object | Specifies when the deletion process should run. | +| `time_limit` | String | Maximum time allowed for snapshot deletion operations before timing out (e.g., "30m" for thirty minutes). | + +
+ +
+ + Request body fields: deletion > condition + + {: .text-delta} + +`condition` is a JSON object with the following fields: + +| Property | Data type | Description | +| :--- | :--- | :--- | +| `max_age` | String | The maximum age of snapshots to retain. Older snapshots will be deleted. | +| `max_count` | Integer | The maximum number of snapshots to retain. When exceeded, older snapshots will be deleted. | +| `min_count` | Integer | The minimum number of snapshots to retain, regardless of age. | + +
+ +
+ + Request body fields: deletion > schedule + + {: .text-delta} + +`schedule` is a JSON object with the following fields: + +| Property | Data type | Description | +| :--- | :--- | :--- | +| `cron` | Object | Defines when the deletion process should run using cron expressions. | + +
+ +
+ + Request body fields: notification + + {: .text-delta} + +The configuration for notification settings and conditions. + +`notification` is a JSON object with the following fields: + +| Property | Data type | Description | +| :--- | :--- | :--- | +| `channel` | Object | Specifies the notification channel to use for sending alerts. | +| `conditions` | Object | Defines which events should trigger notifications. | + +
+ +
+ + Request body fields: notification > channel + + {: .text-delta} + +`channel` is a JSON object with the following fields: + +| Property | Required | Data type | Description | +| :--- | :--- | :--- | :--- | +| `id` | **Required** | String | The unique identifier of the notification channel to use for sending alerts. | + +
+ +
+ + Request body fields: notification > conditions + + {: .text-delta} + +`conditions` is a JSON object with the following fields: + +| Property | Data type | Description | Default | +| :--- | :--- | :--- | :--- | +| `creation` | Boolean | Whether to send notifications when snapshots are successfully created. | `true` | +| `deletion` | Boolean | Whether to send notifications when snapshots are successfully deleted. | `false` | +| `failure` | Boolean | Whether to send notifications when snapshot operations fail. | `false` | +| `time_limit_exceeded` | Boolean | Whether to send notifications when operations exceed their configured time limits. | `false` | + +
+ +
+ + Request body fields: snapshot_config + + {: .text-delta} + +The core configuration for how snapshots should be created and managed. + +`snapshot_config` is a JSON object with the following fields: + +| Property | Required | Data type | Description | +| :--- | :--- | :--- | :--- | +| `repository` | **Required** | String | The name of the repository where snapshots will be stored. | +| `date_format` | Optional | String | Format string for the date portion of snapshot names. Default is `yyyy-MM-dd'T'HH:mm:ss`. | +| `ignore_unavailable` | Optional | Boolean | Whether to ignore unavailable indexes during snapshot creation. Default is `false`. | +| `include_global_state` | Optional | Boolean | Whether to include cluster state in snapshots. Default is `true`. | +| `indices` | Optional | String | Pattern specifying which indexes to include in snapshots. Default is `*` (all indexes). | +| `metadata` | Optional | Object | Custom metadata to attach to snapshots. | +| `partial` | Optional | Boolean | Whether to allow partial snapshots if some shards fail. Default is `false`. | +| `timezone` | Optional | String | Time zone for date formatting in snapshot names. Default is `UTC`. | + +
+ +## Example request + +```json +POST _plugins/_sm/policies/daily-policy +{ + "description": "Daily snapshot policy", + "creation": { + "schedule": { + "cron": { + "expression": "0 8 * * *", + "timezone": "UTC" + } + }, + "time_limit": "1h" + }, + "deletion": { + "schedule": { + "cron": { + "expression": "0 1 * * *", + "timezone": "America/Los_Angeles" + } + }, + "condition": { + "max_age": "7d", + "max_count": 21, + "min_count": 7 + }, + "time_limit": "1h" + }, + "snapshot_config": { + "date_format": "yyyy-MM-dd-HH:mm", + "timezone": "America/Los_Angeles", + "indices": "*", + "repository": "s3-repo", + "ignore_unavailable": "true", + "include_global_state": "false", + "partial": "true", + "metadata": { + "any_key": "any_value" + } + }, + "notification": { + "channel": { + "id": "NC3OpoEBzEoHMX183R3f" + }, + "conditions": { + "creation": true, + "deletion": false, + "failure": false, + "time_limit_exceeded": false + } + } +} +``` +{% include copy-curl.html %} + +## Example response + +```json +{ + "_id" : "daily-policy-sm-policy", + "_version" : 5, + "_seq_no" : 54983, + "_primary_term" : 21, + "sm_policy" : { + "name" : "daily-policy", + "description" : "Daily snapshot policy", + "schema_version" : 15, + "creation" : { + "schedule" : { + "cron" : { + "expression" : "0 8 * * *", + "timezone" : "UTC" + } + }, + "time_limit" : "1h" + }, + "deletion" : { + "schedule" : { + "cron" : { + "expression" : "0 1 * * *", + "timezone" : "America/Los_Angeles" + } + }, + "condition" : { + "max_age" : "7d", + "min_count" : 7, + "max_count" : 21 + }, + "time_limit" : "1h" + }, + "snapshot_config" : { + "indices" : "*", + "metadata" : { + "any_key" : "any_value" + }, + "ignore_unavailable" : "true", + "timezone" : "America/Los_Angeles", + "include_global_state" : "false", + "date_format" : "yyyy-MM-dd-HH:mm", + "repository" : "s3-repo", + "partial" : "true" + }, + "schedule" : { + "interval" : { + "start_time" : 1656425122909, + "period" : 1, + "unit" : "Minutes" + } + }, + "enabled" : true, + "last_updated_time" : 1656425122909, + "enabled_time" : 1656425122909, + "notification" : { + "channel" : { + "id" : "NC3OpoEBzEoHMX183R3f" + }, + "conditions" : { + "creation" : true, + "deletion" : false, + "failure" : false, + "time_limit_exceeded" : false + } + } + } +} +``` + +## Response body fields + +The response body is a JSON object with the following fields: + +| Property | Required | Data type | Description | +| :--- | :--- | :--- | :--- | +| `_id` | **Required** | String | The unique identifier of the created snapshot policy. | +| `_primary_term` | **Required** | Integer | The primary term used for optimistic concurrency control in distributed systems. | +| `_seq_no` | **Required** | Integer | The sequence number used for optimistic concurrency control in distributed systems. | +| `_version` | **Required** | Integer | The internal version number of the policy document. | +| `sm_policy` | **Required** | Object | The complete snapshot management policy configuration as stored in the system. | + +
+ + Response body fields: sm_policy + + {: .text-delta} + +The complete snapshot management policy configuration. + +`sm_policy` is a JSON object with the following fields: + +| Property | Required | Data type | Description | +| :--- | :--- | :--- | :--- | +| `creation` | **Required** | Object | The snapshot creation schedule and configuration. | +| `description` | **Required** | String | The user-provided description of the policy. | +| `name` | **Required** | String | The name of the snapshot policy. | +| `snapshot_config` | **Required** | Object | The core snapshot configuration settings. | +| `deletion` | Optional | Object | The configuration for automatic snapshot deletion. | +| `enabled` | Optional | Boolean | Whether the policy is currently active. | +| `enabled_time` | Optional | Integer | The unix timestamp (in milliseconds) when the policy was last enabled. | +| `last_updated_time` | Optional | Integer | The unix timestamp (in milliseconds) when the policy was last modified. | +| `notification` | Optional | Object | The notification settings for the policy. | +| `schedule` | Optional | Object | The system-generated schedule metadata for policy execution. | +| `schema_version` | Optional | Integer | The version of the policy schema being used. | + +
+ +## Response body fields + +The response body is a JSON object with the following fields: + +| Property | Required | Data type | Description | +| :--- | :--- | :--- | :--- | +| `_id` | **Required** | String | The unique identifier of the created snapshot policy. | +| `_primary_term` | **Required** | Integer | The primary term used for optimistic concurrency control in distributed systems. | +| `_seq_no` | **Required** | Integer | The sequence number used for optimistic concurrency control in distributed systems. | +| `_version` | **Required** | Integer | The internal version number of the policy document. | +| `sm_policy` | **Required** | Object | The complete snapshot management policy configuration as stored in the system. | + +
+ + Response body fields: sm_policy + + {: .text-delta} + +The complete snapshot management policy configuration. + +`sm_policy` is a JSON object with the following fields: + +| Property | Required | Data type | Description | +| :--- | :--- | :--- | :--- | +| `creation` | **Required** | Object | The snapshot creation schedule and configuration. | +| `description` | **Required** | String | The user-provided description of the policy. | +| `name` | **Required** | String | The name of the snapshot policy. | +| `snapshot_config` | **Required** | Object | The core snapshot configuration settings. | +| `deletion` | Optional | Object | The configuration for automatic snapshot deletion. | +| `enabled` | Optional | Boolean | Whether the policy is currently active. | +| `enabled_time` | Optional | Integer | The unix timestamp (in milliseconds) when the policy was last enabled. | +| `last_updated_time` | Optional | Integer | The unix timestamp (in milliseconds) when the policy was last modified. | +| `notification` | Optional | Object | The notification settings for the policy. | +| `schedule` | Optional | Object | System-generated schedule metadata for policy execution. | +| `schema_version` | Optional | Integer | The version of the policy schema being used. | + +
+ +
+ + Response body fields: sm_policy > creation + + {: .text-delta} + +`creation` is a JSON object with the following fields: + +| Property | Required | Data type | Description | +| :--- | :--- | :--- | :--- | +| `schedule` | **Required** | Object | The configured schedule for snapshot creation. | +| `time_limit` | Optional | String | The maximum duration allowed for snapshot creation operations before timing out. | + +
+ +
+ + Response body fields: sm_policy > creation > schedule + + {: .text-delta} + +`schedule` is a JSON object with the following fields: + +| Property | Data type | Description | +| :--- | :--- | :--- | +| `cron` | Object | The cron schedule configuration for snapshot creation. | + +
+ +
+ + Response body fields: sm_policy > creation > schedule > cron + + {: .text-delta} + +`cron` is a JSON object with the following fields: + +| Property | Required | Data type | Description | +| :--- | :--- | :--- | :--- | +| `expression` | **Required** | String | The cron expression defining when snapshots will be created. | +| `timezone` | **Required** | String | The time zone used for interpreting the cron expression. | + +
+ +
+ + Response body fields: sm_policy > deletion + + {: .text-delta} + +`deletion` is a JSON object with the following fields: + +| Property | Data type | Description | +| :--- | :--- | :--- | +| `condition` | Object | The criteria that determine when snapshots should be deleted. | +| `schedule` | Object | The schedule configuration for running deletion operations. | +| `time_limit` | String | The maximum duration allowed for snapshot deletion operations before timing out. | + +
+ +
+ + Response body fields: sm_policy > deletion > condition + + {: .text-delta} + +`condition` is a JSON object with the following fields: + +| Property | Data type | Description | +| :--- | :--- | :--- | +| `max_age` | String | The maximum age of snapshots to retain (e.g., "7d", "30d"). | +| `max_count` | Integer | The maximum number of snapshots to keep before deleting older ones. | +| `min_count` | Integer | The minimum number of snapshots to retain regardless of age. | + +
+ +
+ + Response body fields: sm_policy > deletion > schedule + + {: .text-delta} + +`schedule` is a JSON object with the following fields: + +| Property | Data type | Description | +| :--- | :--- | :--- | +| `cron` | Object | The cron schedule configuration for running deletion operations. | + +
+ +
+ + Response body fields: sm_policy > notification + + {: .text-delta} + +`notification` is a JSON object with the following fields: + +| Property | Data type | Description | +| :--- | :--- | :--- | +| `channel` | Object | The notification channel configuration for sending alerts. | +| `conditions` | Object | The conditions that trigger notifications. | + +
+ +
+ + Response body fields: sm_policy > notification > channel + + {: .text-delta} + +`channel` is a JSON object with the following fields: + +| Property | Required | Data type | Description | +| :--- | :--- | :--- | :--- | +| `id` | **Required** | String | The unique identifier of the configured notification channel. | + +
+ +
+ + Response body fields: sm_policy > notification > conditions + + {: .text-delta} + +`conditions` is a JSON object with the following fields: + +| Property | Data type | Description | Default | +| :--- | :--- | :--- | :--- | +| `creation` | Boolean | Whether notifications are sent for successful snapshot creations. | `true` | +| `deletion` | Boolean | Whether notifications are sent for successful snapshot deletions. | `false` | +| `failure` | Boolean | Whether notifications are sent for failed operations. | `false` | +| `time_limit_exceeded` | Boolean | Whether notifications are sent when operations exceed time limits. | `false` | + +
+ +
+ + Response body fields: sm_policy > schedule + + {: .text-delta} + +`schedule` is a JSON object with the following fields: + +| Property | Data type | Description | +| :--- | :--- | :--- | +| `interval` | Object | The system-generated interval settings for the policy execution. | + +
+ +
+ + Response body fields: sm_policy > schedule > interval + + {: .text-delta} + +`interval` is a JSON object with the following fields: + +| Property | Required | Data type | Description | +| :--- | :--- | :--- | :--- | +| `period` | **Required** | Integer | The number of time units between policy executions. | +| `start_time` | **Required** | Integer | The unix timestamp (in milliseconds) when the interval schedule begins. | +| `unit` | **Required** | String | The time unit for the interval period (Days, Hours, or Minutes). | + +
+ + + + + + + + diff --git a/_api-reference/snapshot-management-apis/delete-policy.md b/_api-reference/snapshot-management-apis/delete-policy.md new file mode 100644 index 00000000000..3ae598143bb --- /dev/null +++ b/_api-reference/snapshot-management-apis/delete-policy.md @@ -0,0 +1,100 @@ +--- +layout: default +title: Delete Policy API +parent: Snapshot Management APIs +nav_order: 55 +--- + +# Delete Policy API + +**Introduced 2.4** +{: .label .label-purple } + +The Delete Policy API removes a snapshot management policy from the system. This operation is permanent and cannot be undone. It is commonly used to deprecate policies that are no longer needed or to clean up test configurations. + + +## Endpoints +```json +DELETE /_plugins/_sm/policies/{policy_name} +``` + + + +## Path parameters + +The following table lists the available path parameters. + +| Parameter | Required | Data type | Description | +| :--- | :--- | :--- | :--- | +| `policy_name` | **Required** | String | The name of the snapshot management policy to delete. | + + + + + +## Example request + +The following example deletes the `daily-snapshots` policy: + +```json +DELETE /_plugins/_sm/policies/daily-snapshots +``` +{% include copy-curl.html %} + +## Example response + +```json +{ + "_id": "daily-snapshots", + "_index": ".opensearch-snapshot-management-policies", + "_primary_term": 1, + "_seq_no": 15, + "_shards": { + "total": 2, + "successful": 2, + "failed": 0 + }, + "_version": 3, + "forced_refresh": true, + "result": "deleted" +} +``` + +## Response body fields + +The response body is a JSON object with the following fields: + +| Property | Required | Data type | Description | +| :--- | :--- | :--- | :---- | +| `_id` | **Required** | String | The ID of the deleted policy. | +| `_index` | **Required** | String | The index name where the policy was stored. | +| `_primary_term` | **Required** | Integer | The primary term for optimistic concurrency control. | +| `_seq_no` | **Required** | Integer | The sequence number for optimistic concurrency control. | +| `_shards` | **Required** | Object | Information about shard operations. | +| `_version` | **Required** | Integer | The version number of the operation. | +| `forced_refresh` | **Required** | Boolean | Whether a refresh was forced after the operation. | +| `result` | **Required** | String | The result of the delete operation. | + +
+ + Response body fields: _shards + + {: .text-delta} + +The `_shards` object provides information about how the operation affected the index shards. + +| Property | Data type | Description | +| :--- | :--- | :---- | +| `failed` | Integer | The number of shards that failed. | +| `successful` | Integer | The number of shards that completed successfully. | +| `total` | Integer | The total number of shards. | + +
+ + diff --git a/_api-reference/snapshot-management-apis/explain-policy.md b/_api-reference/snapshot-management-apis/explain-policy.md new file mode 100644 index 00000000000..dcf0b117802 --- /dev/null +++ b/_api-reference/snapshot-management-apis/explain-policy.md @@ -0,0 +1,204 @@ +--- +layout: default +title: Explain Policy API +parent: Snapshot Management APIs +nav_order: 60 +--- + +# Explain Policy API + +**Introduced 2.4** +{: .label .label-purple } + +The Explain Policy API provides insight into the current state of a snapshot management policy. This API is useful for debugging or monitoring snapshot policy activity, such as understanding when the policy last executed, what triggered the execution, or whether any retries occurred. + + +## Endpoints +```json +GET /_plugins/_sm/policies/{policy_name}/_explain +``` + + + +## Path parameters + +The following table lists the available path parameters. + +| Parameter | Required | Data type | Description | +| :--- | :--- | :--- | :--- | +| `policy_name` | **Required** | String | The name of the snapshot management policy to explain. | + + + +## Example request + +```json +GET /_plugins/_sm/policies/daily-snapshots/_explain +``` +{% include copy-curl.html %} + +## Example response + +```json +{ + "policies": [ + { + "name": "daily-snapshots", + "enabled": true, + "policy_seq_no": 10, + "policy_primary_term": 1, + "creation": { + "current_state": "SUCCESS", + "latest_execution": { + "info": { + "cause": "", + "message": "Snapshot created successfully" + } + }, + "retry": { + "count": 0 + }, + "trigger": { + "time": 1686151296000 + } + }, + "deletion": { + "current_state": "NOT_EXECUTED", + "latest_execution": {}, + "retry": { + "count": 0 + }, + "trigger": { + "time": 0 + } + } + } + ] +} +``` + +## Response body fields + +The response body is a JSON object with the following fields: + +| Property | Data type | Description | +| :---- | :---- | :---- | +| `policies` | Array of objects | A list of snapshot management policies with their current execution state and metadata. | + +
+ + Response body fields: policies + + {: .text-delta} + +Each element in the `policies` array is a JSON object with the following fields: + +| Property | Data type | Description | +| :---- | :--- | :---- | +| `name` | String | The name of the policy. | +| `enabled` | Boolean | Whether the policy is currently enabled. | +| `policy_seq_no` | Integer | The sequence number of the policy. | +| `policy_primary_term` | Integer | The primary term of the policy. | +| `creation` | Object | The snapshot creation execution state. | +| `deletion` | Object | The snapshot deletion execution state. | + +
+ +
+ + Response body fields: policies > creation + + {: .text-delta} + +The `creation` object provides information about snapshot creation policy execution. + +| Property | Data type | Description | +| :--- | :--- | :--- | +| `current_state` | String | The current state of the policy execution. | +| `latest_execution` | Object | Details about the most recent policy execution. | +| `retry` | Object | Information about any retry attempts that occurred. | +| `trigger` | Object | Information about what triggered the policy execution. | + +
+ +
+ + Response body fields: policies > creation > latest_execution + + {: .text-delta} + +The `latest_execution` object contains information about the most recent policy execution. + +| Property | Data type | Description | +| :--- | :--- | :---- | +| `info` | Object | Metadata about the execution result. | + +
+ +
+ + Response body fields: policies > creation > latest_execution > info + + {: .text-delta} + +The `info` object provides messages related to the most recent execution result. + +| Property | Data type | Description | +| :--- | :---- | :--- | +| `cause` | String | The reason policy execution failed, if applicable. | +| `message` | String | A detailed message about the policy execution result. | + +
+ +
+ + Response body fields: policies > creation > retry + + {: .text-delta} + +The `retry` object provides metadata about retry attempts. + +| Property | Data type | Description | +| :--- | :---- | :---- | +| `count` | Integer | The number of retry attempts made. | + +
+ +
+ + Response body fields: policies > creation > trigger + + {: .text-delta} + +The `trigger` object describes the trigger that initiated the policy execution. + +| Property | Data type | Description | +| :--- | :---- | :--- | +| `time` | Integer | The time when the policy was triggered, in epoch milliseconds. | + +
+ +
+ + Response body fields: policies > deletion + + {: .text-delta} + +The `deletion` object provides information about snapshot deletion policy execution. + +| Property | Data type | Description | +| :---- | :---- | :----- | +| `current_state` | String | The current state of the policy execution. | +| `latest_execution` | Object | Details about the most recent policy execution. | +| `retry` | Object | Information about any retry attempts that occurred. | +| `trigger` | Object | Information about what triggered the policy execution. | + +
+ + diff --git a/_api-reference/snapshot-management-apis/get-policy.md b/_api-reference/snapshot-management-apis/get-policy.md new file mode 100644 index 00000000000..1ab369233b5 --- /dev/null +++ b/_api-reference/snapshot-management-apis/get-policy.md @@ -0,0 +1,293 @@ +--- +layout: default +title: Get Snapshot Policy API +parent: Snapshot Management APIs +nav_order: 20 +--- + +# Get Snapshot Policy API +**Introduced 2.4** +{: .label .label-purple } + +The Get Snapshot Policy API retrieves the configuration details of an existing snapshot management policy. This API is useful for verifying policy settings, auditing snapshot configurations, or getting the current state of a policy before making modifications. + +The response includes all policy settings, including creation and deletion schedules, notification configurations, and system-generated metadata such as the last time the policy was enabled or updated. You can use this information to understand how a policy is configured and when it was last modified. + +## Endpoints + +```json +GET /_plugins/_sm/policies/{policy_name} +``` + +## Path parameters + +The following table lists the available path parameters. + +| Parameter | Required | Data type | Description | +| :--- | :--- | :--- | :--- | +| `policy_name` | **Required** | String | The name of the snapshot management policy to retrieve. | + +## Example request + +```bash +GET /_plugins/_sm/policies/daily-snapshots +``` +{% include copy-curl.html %} + +## Example response + +```json +{ + "_id": "daily-snapshots", + "_version": 1, + "_primary_term": 1, + "_seq_no": 0, + "sm_policy": { + "name": "daily-snapshots", + "description": "Takes daily snapshots of all indexes", + "enabled": true, + "enabled_time": 1683849600000, + "last_updated_time": 1683849600000, + "schema_version": 1, + "creation": { + "schedule": { + "cron": { + "expression": "0 0 * * *", + "timezone": "UTC" + } + }, + "time_limit": "1h" + }, + "deletion": { + "schedule": { + "cron": { + "expression": "0 1 * * *", + "timezone": "UTC" + } + }, + "condition": { + "max_age": "30d", + "max_count": 30, + "min_count": 5 + }, + "time_limit": "30m" + }, + "snapshot_config": { + "repository": "my-backup-repo", + "indexes": "*", + "ignore_unavailable": false, + "include_global_state": true, + "partial": false, + "date_format": "yyyy-MM-dd'T'HH:mm:ss", + "timezone": "UTC" + }, + "notification": { + "channel": { + "id": "my-notification-channel" + }, + "conditions": { + "creation": true, + "deletion": false, + "failure": true, + "time_limit_exceeded": true + } + } + } +} +``` + +## Response body fields + +The response body is a JSON object with the following fields: + +| Property | Required | Data type | Description | +| :--- | :--- | :--- | :--- | +| `_id` | **Required** | String | The unique identifier of the snapshot policy. | +| `_primary_term` | **Required** | Integer | The primary term for optimistic concurrency control. Used for cluster coordination. | +| `_seq_no` | **Required** | Integer | The sequence number for optimistic concurrency control. Used for cluster coordination. | +| `_version` | **Required** | Integer | The internal version number of the policy document. Increments with each update. | +| `sm_policy` | **Required** | Object | The complete snapshot management policy configuration. | + +
+ + Response body fields: sm_policy + + {: .text-delta} + +The complete snapshot management policy configuration. + +`sm_policy` is a JSON object with the following fields: + +| Property | Required | Data type | Description | +| :--- | :--- | :--- | :--- | +| `creation` | **Required** | Object | The configuration settings for snapshot creation. | +| `description` | **Required** | String | The description of the policy's purpose. | +| `name` | **Required** | String | The name of the snapshot policy. Must match the policy_name path parameter. | +| `snapshot_config` | **Required** | Object | The core configuration settings for snapshot operations. | +| `deletion` | Optional | Object | The configuration settings for automatic snapshot deletion. | +| `enabled` | Optional | Boolean | Whether the policy is currently active and executing. | +| `enabled_time` | Optional | Integer | The unix timestamp (in milliseconds) when the policy was last enabled. | +| `last_updated_time` | Optional | Integer | The unix timestamp (in milliseconds) of the last policy modification. | +| `notification` | Optional | Object | The settings for notification delivery and triggers. | +| `schedule` | Optional | Object | The system-generated schedule metadata for policy execution. | +| `schema_version` | Optional | Integer | The version number of the policy schema format. | + +
+ +
+ + Response body fields: sm_policy > creation + + {: .text-delta} + +`creation` is a JSON object with the following fields: + +| Property | Required | Data type | Description | +| :--- | :--- | :--- | :--- | +| `schedule` | **Required** | Object | Defines when snapshots should be created. | +| `time_limit` | Optional | String | The maximum duration allowed for snapshot creation before timing out, such as `1h`. | + +
+ +
+ + Response body fields: sm_policy > creation > schedule + + {: .text-delta} + +`schedule` is a JSON object with the following fields: + +| Property | Data type | Description | +| :--- | :--- | :--- | +| `cron` | Object | The cron schedule configuration for snapshot creation. | + +
+ +
+ + Response body fields: sm_policy > creation > schedule > cron + + {: .text-delta} + +`cron` is a JSON object with the following fields: + +| Property | Required | Data type | Description | +| :--- | :--- | :--- | :--- | +| `expression` | **Required** | String | The cron expression that defines when snapshots are created `0 0 * * *` for daily at midnight. | +| `timezone` | **Required** | String | The time zone used for interpreting the cron expression, such as `UTC`. | + +
+ +
+ + Response body fields: sm_policy > deletion + + {: .text-delta} + +`deletion` is a JSON object with the following fields: + +| Property | Data type | Description | +| :--- | :--- | :--- | +| `condition` | Object | The rules that determine when snapshots should be deleted. | +| `schedule` | Object | When deletion operations should run. | +| `time_limit` | String | Maximum duration allowed for deletion operations before timing out . | + +
+ +
+ + Response body fields: sm_policy > deletion > condition + + {: .text-delta} + +`condition` is a JSON object with the following fields: + +| Property | Data type | Description | +| :--- | :--- | :--- | +| `max_age` | String | The maximum age of snapshots to retain (e.g., "30d" for 30 days). Older snapshots are eligible for deletion. | +| `max_count` | Integer | The maximum number of snapshots to retain. When exceeded, older snapshots become eligible for deletion. | +| `min_count` | Integer | The minimum number of snapshots to retain, regardless of age. Prevents deletion if count would drop below this number. | + +
+ +
+ + Response body fields: sm_policy > deletion > schedule + + {: .text-delta} + +`schedule` is a JSON object with the following fields: + +| Property | Data type | Description | +| :--- | :--- | :--- | +| `cron` | Object | The cron schedule configuration for running deletion operations. This contains the same structure as the creation schedule cron job. | + +
+ +
+ + Response body fields: sm_policy > notification + + {: .text-delta} + +`notification` is a JSON object with the following fields: + +| Property | Data type | Description | +| :--- | :--- | :--- | +| `channel` | Object | The configuration for the notification delivery channel. | +| `conditions` | Object | The settings that determine which events trigger notifications. | + +
+ +
+ + Response body fields: sm_policy > notification > channel + + {: .text-delta} + +`channel` is a JSON object with the following fields: + +| Property | Required | Data type | Description | +| :--- | :--- | :--- | :--- | +| `id` | **Required** | String | The unique identifier of the notification channel to use for sending alerts. | + +
+ +
+ + Response body fields: sm_policy > notification > conditions + + {: .text-delta} + +`conditions` is a JSON object with the following fields: + +| Property | Data type | Description | Default | +| :--- | :--- | :--- | :--- | +| `creation` | Boolean | Whether to send notifications for successful snapshot creations. | `true` | +| `deletion` | Boolean | Whether to send notifications for successful snapshot deletions. | `false` | +| `failure` | Boolean | Whether to send notifications for any failed operations. | `false` | +| `time_limit_exceeded` | Boolean | Whether to send notifications when operations exceed their time limits. | `false` | + +
+ +
+ + Response body fields: sm_policy > snapshot_config + + {: .text-delta} + +`snapshot_config` is a JSON object with the following fields: + +| Property | Required | Data type | Description | +| :--- | :--- | :--- | :--- | +| `repository` | **Required** | String | The name of the repository where snapshots are stored. | +| `date_format` | Optional | String | The format string for the date portion of snapshot names. Default is `yyyy-MM-dd'T'HH:mm:ss`. | +| `ignore_unavailable` | Optional | Boolean | Whether to ignore unavailable indexes during snapshot creation. Default is `false`. | +| `include_global_state` | Optional | Boolean | Whether to include cluster state in snapshots. Default is `true`. | +| `indexes` | Optional | String | Pattern specifying which indexes to include in snapshots. Default is `*`. | +| `metadata` | Optional | Object | The custom metadata attached to snapshots created by this policy. | +| `partial` | Optional | Boolean | Whether to allow partial snapshots if some shards fail. Default is `false`. | +| `timezone` | Optional | String | The time zone for date formatting in snapshot names. Default is `UTC`. | + +
+ diff --git a/_api-reference/snapshot-management-apis/index.md b/_api-reference/snapshot-management-apis/index.md new file mode 100644 index 00000000000..b24bf3bc46c --- /dev/null +++ b/_api-reference/snapshot-management-apis/index.md @@ -0,0 +1,58 @@ +--- +layout: default +title: Snapshot Management APIs +has_children: true +nav_order: 81 +--- + +# Snapshot Management APIs + +**Introduced in 2.4** +{: .label .label-purple } + +Snapshot Management APIs let you automate the scheduling, creation, retention, and lifecycle of snapshots in OpenSearch. These APIs help safeguard data, reduce storage costs, and simplify administrative tasks by using policies instead of manual snapshot operations. + +## What is snapshot management? + +Snapshot management allows you to define policies that control when snapshots are created, how they're configured, and when they're deleted. Each policy includes creation rules and optional deletion criteria, and can be enabled or disabled as needed. + +These policies are useful in environments with large or frequently updated data, where manual snapshotting is inefficient or error-prone. Snapshot management ensures consistent backup strategies, improves recoverability, and supports compliance requirements without manual effort. + +## Use cases + +Snapshot management supports the following operational goals: + +- **Automated backups** – Regularly snapshot critical indexes or clusters using defined policies. +- **Data retention** – Delete outdated snapshots based on age or count. +- **Disaster recovery** – Maintain recoverable cluster states to protect against accidental data loss. +- **Compliance** – Meet audit and regulatory requirements with consistent snapshot intervals and retention periods. +- **Operational efficiency** – Minimize manual effort and reduce the risk of human error. + +## Available APIs + +Use the following APIs to manage snapshot policies: + +- [Create policy API]({{site.url}}{{site.baseurl}}/api-reference/snapshot-management-apis/create-policy/) – Define a new snapshot policy. +- [Get policy API]({{site.url}}{{site.baseurl}}/api-reference/snapshot-management-apis/get-policy/) – Retrieve one or more snapshot policies. +- [Update policy API]({{site.url}}{{site.baseurl}}/api-reference/snapshot-management-apis/update-policy/) – Modify an existing snapshot policy. +- [Delete policy API]({{site.url}}{{site.baseurl}}/api-reference/snapshot-management-apis/delete-policy/) – Remove a snapshot policy. +- [Start policy API]({{site.url}}{{site.baseurl}}/api-reference/snapshot-management-apis/start-policy/) – Manually trigger a snapshot policy. +- [Explain policy API]({{site.url}}{{site.baseurl}}/api-reference/snapshot-management-apis/explain-policy/) – View a policy’s current state and execution history. + +## Security considerations + +Because snapshot policies can automate access to stored data, keep the following security recommendations in mind: + +- Use fine-grained permissions to control who can manage policies. +- Restrict start or modification actions to trusted users or roles. +- Audit policies regularly to ensure alignment with security and business requirements. + +## Best practices + +To optimize your use of snapshot management, remember the following best practices: + +* **Start small** – Test policies on non-production data before applying them in production environments. +* **Align with SLAs** – Set snapshot frequency and retention to meet recovery and compliance requirements. +* **Monitor results** – Use the Explain API and logs to verify policy behavior. +* **Set timeouts** – Limit creation and deletion durations to prevent long-running jobs. +* **Review storage usage** – Periodically evaluate storage consumption and adjust retention rules as needed. diff --git a/_api-reference/snapshot-management-apis/start-policy.md b/_api-reference/snapshot-management-apis/start-policy.md new file mode 100644 index 00000000000..b5eb20d9eac --- /dev/null +++ b/_api-reference/snapshot-management-apis/start-policy.md @@ -0,0 +1,54 @@ +--- +layout: default +title: Start Policy API +parent: Snapshot Management APIs +nav_order: 30 +--- + +# Start Policy API +**Introduced 2.4** +{: .label .label-purple } + +The Start Policy API enables a snapshot management policy that is currently disabled. Once enabled, the policy will begin creating and managing snapshots according to its configured schedule. This API is useful when you need to resume snapshot operations after temporarily disabling a policy or when activating a newly created policy that was initially disabled. + +When you start a policy, the system records the enabled time and begins monitoring the schedule to determine when to create the next snapshot. If the policy includes deletion rules, these will also become active, potentially triggering the cleanup of old snapshots based on the configured conditions. + + +## Endpoints +```json +POST /_plugins/_sm/policies/{policy_name}/_start +``` + + + +## Path parameters + +The following table lists the available path parameters. + +| Parameter | Required | Data type | Description | +| :--- | :--- | :--- | :--- | +| `policy_name` | **Required** | String | The name of the snapshot management policy to start. | + + + +## Example request + +```bash +POST /_plugins/_sm/policies/daily-snapshots/_start +``` +{% include copy-curl.html %} + +## Example response + +```json +{ + "acknowledged": true, +} +``` + diff --git a/_api-reference/snapshot-management-apis/stop-policy.md b/_api-reference/snapshot-management-apis/stop-policy.md new file mode 100644 index 00000000000..5718afa61c2 --- /dev/null +++ b/_api-reference/snapshot-management-apis/stop-policy.md @@ -0,0 +1,56 @@ +--- +layout: default +title: Stop Policy API +parent: Snapshot Management APIs +nav_order: 40 +--- + +# Stop Policy API +**Introduced 2.4** +{: .label .label-purple } + +The Stop Policy API disables an active snapshot management policy. When stopped, the policy will no longer create new snapshots or perform deletion operations, regardless of its configured schedule. This API is useful when you need to temporarily suspend snapshot operations for maintenance, troubleshooting, or resource management. + +Stopping a policy does not affect existing snapshots or delete any configuration. The policy can be restarted later using the Start Policy API, at which point it will resume operations according to its schedule. + + +## Endpoints +```json +POST /_plugins/_sm/policies/{policy_name}/_start +``` + + + +## Path parameters + +The following table lists the available path parameters. + +| Parameter | Required | Data type | Description | +| :--- | :--- | :--- | :--- | +| `policy_name` | **Required** | String | The name of the snapshot management policy to start. | + + + +## Example request + +```bash +POST /_plugins/_sm/policies/daily-snapshots/_stop +``` +{% include copy-curl.html %} + +## Example response + +```json +{ + "acknowledged": true +} +``` + + + diff --git a/_api-reference/snapshot-management-apis/update-policy.md b/_api-reference/snapshot-management-apis/update-policy.md new file mode 100644 index 00000000000..7ee5447a93d --- /dev/null +++ b/_api-reference/snapshot-management-apis/update-policy.md @@ -0,0 +1,209 @@ +--- +layout: default +title: Update Policy API +parent: Snapshot Management APIs +nav_order: 50 +--- + +# Update Policy API + +**Introduced 2.4** +{: .label .label-purple } + +The Update Policy API modifies an existing snapshot management policy. This API is useful when you want to change the schedule, snapshot configuration, deletion conditions, or notification settings of a policy without having to delete and recreate it. + +To ensure consistency, this operation uses optimistic concurrency control. You must supply the current `primary_term` and `seq_no` of the policy you want to update. + + +## Endpoints +```json +PUT /_plugins/_sm/policies/{policy_name} +``` + + + +## Path parameters + +The following table lists the available path parameters. + +| Parameter | Required | Data type | Description | +| :--- | :--- | :--- | :--- | +| `policy_name` | **Required** | String | The name of the snapshot management policy to update. | + + + + +## Query parameters + +The following table lists the available query parameters. + +| Parameter | Required | Data type | Description | +| :--- | :--- | :--- | :--- | +| `if_primary_term` | **Required** | Integer | The primary term of the policy to update. | +| `if_seq_no` | **Required** | Integer | The sequence number of the policy to update. | + + + +## Request body fields + +The request body is optional. It is a JSON object with the following fields: + +| Property | Required | Data type | Description | Default | +| :--- | :--- | :---- | :--- | :--- | +| `creation` | **Required** | Object | Defines when and how often snapshots should be created. | N/A | +| `snapshot_config` | **Required** | Object | Specifies the snapshot settings, including repository, indexes to back up, and other snapshot options. | N/A | +| `deletion` | Optional | Object | Configures automatic cleanup of old snapshots based on age or count conditions. | N/A | +| `description` | Optional | String | A human-readable description of the snapshot policy's purpose. | N/A | +| `enabled` | Optional | Boolean | Whether the policy should start executing upon creation. | `true` | +| `notification` | Optional | Object | Configures when and how to send notifications about snapshot operations. | N/A | + +
+ + Request body fields: creation + + {: .text-delta} + +The configuration for the snapshot creation schedule. + +`creation` is a JSON object with the following fields: + +| Property | Required | Data type | Description | +| :---| :--- | :--- | :---- | +| `schedule` | **Required** | Object | Defines when snapshots should be created using a cron schedule. | +| `time_limit` | Optional | String | The maximum amount of time allowed for snapshot creation. | + +
+ +
+ + Request body fields: creation > schedule + + {: .text-delta} + +`schedule` is a JSON object with the following fields: + +| Property | Data type | Description | +| :--- | :--- | :---- | +| `cron` | Object | Defines the snapshot schedule using cron expressions. Required for creating periodic snapshots. | + +
+ +
+ + Request body fields: creation > schedule > cron + + {: .text-delta} + +`cron` is a JSON object with the following fields: + +| Property | Required | Data type | Description | +| :--- | :---- | :-------- | :---- | +| `expression` | **Required** | String | The standard cron expression that defines when snapshots should be created, such as `0 0 * * *` for daily at midnight. | +| `timezone` | **Required** | String | The time zone used for interpreting the cron expression such as `UTC`, `America/Los_Angeles`. | + +
+ +## Example request + +The following example updates the `daily-snapshots` policy: + +```json +PUT /_plugins/_sm/policies/daily-snapshots?if_primary_term=1&if_seq_no=5 +{ + "enabled": true, + "description": "Updated policy with a new schedule.", + "creation": { + "schedule": { + "cron": { + "expression": "0 0 12 * * ?", + "timezone": "UTC" + } + }, + "time_limit": "15m" + }, + "snapshot_config": { + "repository": "my-repo", + "indices": "logs-*", + "include_global_state": true + } +} +``` +{% include copy-curl.html %} + +## Example response + +```json +{ + "_id": "daily-snapshots", + "_primary_term": 1, + "_seq_no": 6, + "_version": 2, + "sm_policy": { + "name": "daily-snapshots", + "description": "Updated policy with a new schedule.", + "enabled": true, + "creation": { + "schedule": { + "cron": { + "expression": "0 0 12 * * ?", + "timezone": "UTC" + } + }, + "time_limit": "15m" + }, + "snapshot_config": { + "repository": "my-repo", + "indices": "logs-*", + "include_global_state": true + }, + "last_updated_time": 1686105472000 + } +} +``` + +## Response body fields + +The response body is a JSON object with the following fields: + +| Property | Required | Data type | Description | +| :---- | :--- | :--- | :---- | +| `_id` | **Required** | String | The unique identifier of the policy. | +| `_primary_term` | **Required** | Integer | The primary term for optimistic concurrency control. | +| `_seq_no` | **Required** | Integer | The sequence number for optimistic concurrency control. | +| `_version` | **Required** | Integer | The version number of the policy document. | +| `sm_policy` | **Required** | Object | The complete snapshot management policy configuration. | + +
+ + Response body fields: sm_policy + + {: .text-delta} + +The `sm_policy` object includes the full snapshot management policy definition as it exists after the update. + +| Property | Required | Data type | Description | +| :--- | :---- | :--- | :--- | +| `creation` | **Required** | Object | The snapshot creation configuration. | +| `description` | **Required** | String | A user-provided description of the snapshot policy. | +| `name` | **Required** | String | The unique name of the snapshot policy. | +| `snapshot_config` | **Required** | Object | The snapshot configuration settings. | +| `deletion` | Optional | Object | The snapshot deletion configuration. | +| `enabled` | Optional | Boolean | Whether the policy is currently enabled. | +| `enabled_time` | Optional | Integer | A timestamp indicating when the policy was enabled. | +| `last_updated_time` | Optional | Integer | A timestamp of the most recent policy update. | +| `notification` | Optional | Object | The notification configuration. | +| `schedule` | Optional | Object | The internal system-generated schedule metadata. | +| `schema_version` | Optional | Integer | The internal schema version number of the policy. | + +
+ +