Creates an automatic snapshot policy within a specified region. Automatic snapshot policies allow Elastic Compute Service (ECS) to create snapshots and back up data for a disk on a regular basis. These policies can be applied to both system disks and data disks.
Description
When you call this operation to create an automatic snapshot policy, you can specify the days of the week on which to create automatic snapshots, the retention period of the automatic snapshots, and cross-region replication for snapshots in the policy to meet your diverse data backup requirements. After you create an automatic snapshot policy, you must call the ApplyAutoSnapshotPolicy operation to apply it to disks. If you want to modify the automatic snapshot policy, you must call the ModifyAutoSnapshotPolicyEx operation.
When you call this operation, take note of the following items:
- You can create a maximum of 100 automatic snapshot policies within each region for a single Alibaba Cloud account.
- If an automatic snapshot is being created when the time scheduled for creating another automatic snapshot is due, the new snapshot task is skipped. This may occur when a disk contains a large volume of data. For example, you have scheduled snapshots to be created at 09:00:00, 10:00:00, 11:00:00, and 12:00:00 for a disk. The system starts to create a snapshot for the disk at 09:00:00. The process takes 80 minutes because the disk contains a large volume of data and ends at 10:20:00. The system skips the automatic snapshot task scheduled for 10:00:00 and creates the next automatic snapshot for the disk at 11:00:00.
- For information about how to copy a snapshot from one region to another, see the "Background information" section in Copy a snapshot.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | CreateAutoSnapshotPolicy |
The operation that you want to perform. Set the value to CreateAutoSnapshotPolicy. |
regionId | String | Yes | cn-hangzhou |
The ID of the region in which to create the automatic snapshot policy. You can call the DescribeRegions operation to query the most recent region list. |
autoSnapshotPolicyName | String | No | TestName |
The name of the automatic snapshot policy. The name must be 2 to 128 characters in length. It must start with a letter and cannot start with http:// or https://. It can contain letters, digits, colons (:), underscores (_), and hyphens (-). This parameter is empty by default. |
timePoints | String | Yes | ["0", "1", … "23"] |
The points in time of the day at which to create automatic snapshots. The time must be in UTC+8. Unit: hours. Valid values are 0 to 23, which correspond to the 24 points in time on the hour from 00:00:00 to 23:00:00. 1 indicates 01:00:00.
|
repeatWeekdays | String | Yes | ["1","2"] |
The days of the week on which to create automatic snapshots. Valid values: 1 to 7, which correspond to Monday to Sunday. 1 indicates Monday.
|
retentionDays | Integer | Yes | 30 |
The retention period of the automatic snapshot. Unit: days. Valid values:
Default value: -1. |
EnableCrossRegionCopy | Boolean | No | false |
Specifies whether to enable cross-region replication for snapshots.
|
TargetCopyRegions | String | No | ["cn-hangzhou"] |
The destination region to which to copy snapshots. You can set only a single destination region. |
CopiedSnapshotsRetentionDays | Integer | No | 30 |
The retention period of the snapshot copy in the destination region. Unit: days. Valid values:
Default value: -1. |
ResourceGroupId | String | No | rg-aek2kkmhmhs**** |
The ID of the resource group to which the automatic snapshot policy belongs. |
Tag.N.Key | String | No | TestKey |
The key of tag N of the automatic snapshot policy. Valid values of N: 1 to 20. The tag key cannot be an empty string. It can be up to 128 characters in length and cannot start with acs: or aliyun. It cannot contain http:// or https://. |
Tag.N.Value | String | No | TestValue |
The value of tag N of the automatic snapshot policy. Valid values of N: 1 to 20. The tag value can be an empty string. It can be up to 128 characters in length. It cannot start with acs: or contain http:// or https://. |
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
AutoSnapshotPolicyId | String | sp-bp12m37ccmxvbmi5**** |
The ID of the automatic snapshot policy. |
RequestId | String | 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E |
The ID of the request. |
Examples
Sample requests
https://ecs.aliyuncs.com/?Action=CreateAutoSnapshotPolicy
®ionId=cn-hangzhou
&repeatWeekdays=["1"]
&retentionDays=30
&timePoints=["0", "19"]
&autoSnapshotPolicyName=TestName
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<CreateAutoSnapshotPolicyResponse>
<RequestId>F3CD6886-D8D0-4FEE-B93E-1B73239673DE</RequestId>
<AutoSnapshotPolicyId>sp-bp12m37ccmxvbmi5****</AutoSnapshotPolicyId>
</CreateAutoSnapshotPolicyResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "F3CD6886-D8D0-4FEE-B93E-1B73239673DE",
"AutoSnapshotPolicyId" : "sp-bp12m37ccmxvbmi5****"
}
Error codes
HTTP status code | Error code | Error message | Description |
---|---|---|---|
400 | DiskCategory.OperationNotSupported | The type of the specified disk does not support creating a snapshot. | The error message returned because the operation is not supported by the current disk category. |
400 | Duplicate.TagKey | The Tag.N.Key contain duplicate key. | The error message returned because the specified tag key already exists. Tag keys must be unique. |
400 | InvalidTagKey.Malformed | The specified Tag.n.Key is not valid. | The error message returned because the specified Tag.N.Key parameter is invalid. |
400 | InvalidTagValue.Malformed | The specified Tag.n.Value is not valid. | The error message returned because the specified Tag.N.Value parameter is invalid. |
403 | ParameterInvalid | The specified RegionId parameter is invalid. | The error message returned because the specified regionId parameter is invalid. |
403 | ParameterInvalid | The specified RepeatWeekDays parameter is invalid. | The error message returned because the specified repeatWeekDays parameter is invalid. |
403 | ParameterInvalid | The specified TimePoints parameter is invalid. | The error message returned because the specified timePoints parameter is invalid. |
403 | ParameterInvalid | The specified RetentionDays parameter is invalid. | The error message returned because the specified retentionDays parameter is invalid. |
403 | AutoSnapshotPolicy.QuotaExceed | The maximum number of automatic snapshot policy has been reached. | The error message returned because the maximum number of automatic snapshot policies has been reached. |
403 | InvalidAccountStatus.NotEnoughBalance | Your account does not have enough balance. | The error message returned because your account balance is insufficient. Add funds to your account and try again. |
403 | InvalidAccountStatus.SnapshotServiceUnavailable | Snapshot service has not been opened yet. | The error message returned because the operation is not supported while the snapshot service is not activated. |
For a list of error codes, visit the API Error Center.