Creates an automatic snapshot policy. You can apply the automatic snapshot policies to disk (ApplyAutoSnapshotPolicy). Alternatively, you can modify automatic snapshot policies (ModifyAutoSnapshotPolicyEx) later.

Description

When you call this interface, consider the following:

  • You can create up to 100 automatic snapshot policies in each region.

  • If a disk contains a large volume of data and the snapshot creation time exceeds an interval of the two scheduled automatic snapshot time points, no snapshot is taken at the second time point.

    Sample: Jimmy sets the automatic snapshot creation scheduled at 09:00, 10:00, 11:00, and 12:00. The first automatic snapshot starts at 09:00 and is finished at 10:20, and the actually consumed time is 80 minutes. Therefore, the snapshot task scheduled at 10:00 is skipped and another automatic snapshot is created for Jimmy at 11:00.

Request parameters

Name Type Required Description
Action String Yes The name of this interface. Value: CreateAutoSnapshotPolicy.
RegionId String Yes The region of the automatic snapshot policy. For more information, see Regions and zones, or call DescribeRegions to obtain the latest region list.
TimePoints String Yes The automatic snapshot creation schedule, and the unit of measurement is hour. Value range: [0, 23], which represents from 00:00 to 24:00,  for example 1 indicates 01:00. When you want to schedule multiple automatic snapshot tasks for a disk in a day, you can set the TimePoints to an array.
  • A maximum of 24 time points can be selected.
  • The format is  an JSON array of ["0", "1", … "23"] and the time points are separated by commas (,).
RepeatWeekdays String Yes The automatic snapshot repetition dates. The unit of measurement is day and the repeating cycle is a week. Value range: [1, 7], which represents days starting from Monday to Sunday, for example 1  indicates Monday. When you want to schedule multiple automatic snapshot tasks for a disk in a week, you can set the RepeatWeekdays to an array.
  • A maximum of seven time points can be selected.
  • The format is  an JSON array of ["1", "2", … "7"]  and the time points are separated by commas (,).
RetentionDays Integer Yes The snapshot retention time, and the unit of measurement is day. Optional values:
  • -1: The automatic snapshots are retained permanently.
  • [1, 65536]: The number of days retained.
Default value: -1.
AutoSnapshotPolicyName String No The name of the automatic snapshot policy.
  • It can consist of [2, 128] English or Chinese characters.
  • Must begin with an uppercase or lowercase letter or a Chinese character. Can contain numbers, periods (.), colons (:), underscores (_), and hyphens (-).
  • Cannot start with http:// or https://.
Default value: null.
ClientToken String No Guarantees the idempotence of the request. The value is generated by a client. It must be unique among all requests and contains a maximum of 64 ASCII characters. For more information, see How to ensure idempotence.

Response parameters

Name Type Description
AutoSnapshotPolicyId String The automatic snapshot policy ID.

Examples

Request example
https://ecs.aliyuncs.com/?Action=CreateAutoSnapshotPolicy
&RegionId=cn-hangzhou
&TimePoints=[“0”, “11 ”, “21 ”]
&RepeatWeekdays=[“1” ,“2” ,“4” ,“7”]
&RetentionDays=30
&<Common Request Parameters>
Response example

XML format

<CreateAutoSnapshotPolicyResponse>
    <RequestId>F3CD6886-D8D0-4FEE-B93E-1B73239673DE</RequestId>
    <AutoSnapshotPolicyId>p-233e6ylv0</AutoSnapshotPolicyId>
</CreateAutoSnapshotPolicyResponse>
JSON format
{
    "RequestId":"F3CD6886-D8D0-4FEE-B93E-1B73239673DE"
    "AutoSnapshotPolicyId":"p-233e6ylv0"
}

Error codes

The following error codes are specific to this interface. For more error codes, visit the API error center.

Error code Error message HTTP status code Meaning
AutoSnapshotPolicy.QuotaExceed The maximum number of automatic snapshot policy has been reached. 403 An Alibaba Cloud account can create up to 100 automatic snapshot policies in one region.
ParameterInvalid The specified RegionId parameter is invalid. 404 The specified RegionId parameter is invalid.
ParameterInvalid The specified RepeatWeekDays parameter is invalid. 404 The specified RepeatWeekDays parameter is invalid.
ParameterInvalid The specified RetentionDays parameter is invalid. 404 The specified RetentionDays parameter is invalid.
ParameterInvalid The specified TimePoints parameter is invalid. 404 The specified TimePoints parameter is invalid.