Function
This API is used to configure automatic snapshot creation policies for an Elasticsearch or OpenSearch cluster. When automatic snapshot creation is enabled, snapshots are automatically created daily or weekly based on a preset time schedule, ensuring ongoing data protection. By configuring an automatic snapshot policy, you reduce manual operations while improving backup reliability and efficiency.
URI
POST /v1.0/{project_id}/clusters/{cluster_id}/index_snapshot/policy
Table 1 Path Parameters | Parameter | Mandatory | Type | Description |
| project_id | Yes | String | Definition Project ID. For details about how to obtain the project ID and name, see Obtaining the Project ID and Name. Constraints N/A Range Project ID of an account. The value contains 32 characters, consisting of lowercase letters and digits. Default Value N/A |
| cluster_id | Yes | String | Definition ID of the cluster for which you want to enable automatic snapshot creation. For details about how to obtain the cluster ID, see Obtaining the Cluster ID. Constraints N/A Range The value is a UUID containing 36 characters. Default Value N/A |
Request Parameters
Table 2 Request body parameters | Parameter | Mandatory | Type | Description |
| indices | No | String | Definition Name of the index to be backed up. Constraints -
If no index is specified, snapshots will be created for all indexes in the cluster. -
You can use an asterisk () to match multiple indexes. For example, index indicates that all indexes with the prefix index will be backed up. -
Or you can back up indexes by specifying their names, for example, index1,index2,index3. -
The value can contain a maximum of 1,024 characters and cannot contain uppercase letters, spaces, or the following special characters: "<|>/? Range The value can contain 0 to 1,024 characters. It cannot contain uppercase letters, spaces, or the following special characters: "<|>/? Default Value The default value is empty, indicating that all indexes will be backed up. |
| prefix | No | String | Definition: Prefix of the name of an automatically created snapshot. A snapshot name consists of the snapshot name prefix and timestamp, for example, snapshot-1566921603720. Constraints: This parameter is mandatory when enable is set to true. Value range: Enter up to 32 characters and start with a lowercase letter. Lowercase letters, digits, hyphens (-), and underscores (_) are allowed. Default value: N/A |
| period | No | String | Definition Time of day to create a snapshot. Constraints When frequency is HOUR, period does not need to be specified. The snapshot is created by default at the next hour on the hour after the setting takes effect. Range Snapshots can only be created on the hour. The time zone must be appended. Format: HH:mm z, where HH:mm indicates the hour and z indicates the time zone. For example, 00:00 GMT+08:00, 01:00 GMT+08:00, etc. Default Value 00:00 GMT+08:00 |
| keepday | No | Integer | Definition Customize the number of snapshots to be retained. Expired snapshots will be automatically deleted on the half hour. The deletion policy applies only to auto snapshots that are executed at the same frequency as the current automatic snapshot creation policy. Constraints -
This parameter is mandatory when enable is set to true. -
The number of retained snapshots depends on the execution frequency and indexes set in the automatic snapshot creation policy. If the execution interval is short or the index data volume is large, the number of retained automatic snapshots may not reach the preset value. Range 1 to 90 Default Value N/A |
| enable | Yes | String | Definition: Whether to enable automatic snapshot creation. Constraints: N/A Value range: Default value: false |
| delete_auto | No | String | Definition: Whether to clear all the automatically created snapshots when disabling automatic snapshot creation. Constraints: If automatic snapshot creation is disabled without deleting automatically created snapshots, all such snapshots in the cluster cannot be manually deleted later once automatic snapshot creation is enabled again. Instead, they can only be deleted by the system based on the snapshot lifecycle policy. Value range: Default value: false |
| frequency | No | String | Definition: Frequency of automatically creating snapshots. Constraints: The number of retained snapshots depends on the execution frequency and indexes set in the automatic snapshot creation policy. If the execution interval is short or the index data volume is large, the number of retained automatic snapshots may not reach the preset value. Value range: -
HOUR: Execute once every hour on the hour. -
DAY: Execute once every day. -
SUN, MON, TUE, WED, THU, FRI, and SAT: Execute the task at the specified day of every week. For example, SUN indicates that the task is executed once every Sunday. Default value: DAY |
Response Parameters
Status code: 200
Request succeeded.
None
Example Requests
Configure the automatic snapshot creation policy.
POST https://{Endpoint}/v1.0/{project_id}/clusters/4f3deec3-efa8-4598-bf91-560aad1377a3/index_snapshot/policy
{
"prefix" : "snapshot",
"period" : "16:00 GMT+08:00",
"keepday" : 7,
"frequency" : "DAY",
"enable" : "true",
"delete_auto" : "false"
} Status Codes
| Status Code | Description |
| 200 | Request succeeded. |
| 406 | The server could not fulfill the request according to the content characteristics of the request. |