Help Center/ Cloud Search Service/ API Reference/ APIs/ Snapshot Management/ Configuring the Automatic Snapshot Creation Policy
Updated on 2024-10-17 GMT+08:00

Configuring the Automatic Snapshot Creation Policy

Function

This API is used to configure automatic snapshot creation. By default, a snapshot is created every day.

Debugging

You can debug this API through automatic authentication in API Explorer.

URI

POST /v1.0/{project_id}/clusters/{cluster_id}/index_snapshot/policy

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain the project ID and name, see Obtaining the Project ID and Name.

cluster_id

Yes

String

ID of the cluster for which you want to create snapshots automatically.

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

indices

No

String

Name of the index to be backed up. * indicates all indexes.

prefix

No

String

Prefix of a snapshot that is automatically created, which is manually entered.

Enter up to 32 characters and start with a lowercase letter. Lowercase letters, digits, hyphens (-), and underscores (_) are allowed.

NOTE:

This parameter is mandatory when enable is set to true.

period

No

String

Time when a snapshot is generated every day. Snapshots can only be generated on the hour. The format is HH:mm z: HH:mm refers to the hour time and z refers to the time zone. For example, 00:00 GMT+08:00 and 01:00 GMT+08:00.

NOTE:

The default value is 00:00 GMT+08:00. When frequency is set to HOUR, you do not need to specify period. By default, snapshot creation starts from the next hour after the settings are successful. This parameter is mandatory when enable is set to true.

keepday

No

Integer

Set the number of retained snapshots. The value ranges from 1 to 90. Expired snapshots will be automatically deleted on the half hour. The deletion policy applies only to automated snapshots that are executed at the same frequency as the current automatic snapshot creation policy.

NOTE:

This parameter is mandatory when enable is set to true.

enable

Yes

String

Whether to enable the automatic snapshot creation policy.

  • true: The automatic snapshot creation policy is enabled.

  • false:The automatic snapshot creation policy is disabled, and other parameters do not need to be delivered.

deleteAuto

No

String

Whether to clear all the automatically created snapshots when the automatic snapshot creation policy is disabled. The default value is false, indicating that automatically created snapshots will not be deleted. If this parameter is set to true, all created snapshots will be deleted when the automatic snapshot creation policy is disabled.

frequency

No

String

Frequency of automatically creating snapshots.

NOTE:

The default value is DAY. If this parameter is set to HOUR, the scheduled task is executed every hour. If this parameter is set to DAY, the scheduled task is executed every day. If this parameter is set to SUN, MON, TUE, WED, THU, FRI or SAT, the scheduled task is executed at the specified day of every week. For example, SUN indicates that the task is executed once every Sunday. 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. Set this value based on actual conditions.

Response Parameters

None

Example Requests

Configure the automatic snapshot creation policy.

POST /v1.0/6204a5bd270343b5885144cf9c8c158d/clusters/4f3deec3-efa8-4598-bf91-560aad1377a3/index_snapshot/policy

{
  "prefix" : "snapshot",
  "period" : "16:00 GMT+08:00",
  "keepday" : 7,
  "frequency" : "DAY",
  "enable" : "true",
  "deleteAuto" : "false"
}

Example Responses

None

Status Codes

Status Code

Description

200

Request succeeded.

406

The server could not fulfill the request according to the content characteristics of the request.

Error Codes

See Error Codes.