Creates an automatic snapshot policy in a specified region. You can specify the repeat cycle, retention period, and cross-region backup settings for automatic snapshots to back up data on system disks or data disks.
Operation description
Before you call this operation, read Create an automatic snapshot policy.
When you call this operation, take note of the following items:
-
You can create a maximum of 100 automatic snapshot policies per region for an Alibaba Cloud account. When the number of automatic snapshots for a disk reaches the quota limit, the system deletes the earliest automatic snapshot created by the automatic snapshot policy when a new snapshot task is initiated.
-
The system does not execute automatic snapshot policies when an ECS instance has a pending stop or restart task.
-
If cross-region snapshot replication is enabled and no encryption parameters are configured, encrypted snapshots are encrypted by using the service key of the destination region by default. For more information about cross-region snapshot replication, see Copy a snapshot.
After you create an automatic snapshot policy, call ApplyAutoSnapshotPolicy to apply the policy to the target disks. To modify an automatic snapshot policy, call ModifyAutoSnapshotPolicyEx.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
ecs:CreateAutoSnapshotPolicy |
create |
*AutoSnapshotPolicy
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| regionId |
string |
Yes |
The region ID of the automatic snapshot policy. You can call DescribeRegions to query the most recent region list. |
cn-hangzhou |
| autoSnapshotPolicyName |
string |
No |
The name of the automatic snapshot policy. The name must be 2 to 128 characters in length. The name must start with a letter and cannot start with http:// or https://. The name can contain digits, colons (:), underscores (_), and hyphens (-). Default value: null. |
TestName |
| timePoints |
string |
Yes |
The points in time at which automatic snapshots are created. The time is displayed in UTC+8. Unit: hours. Valid values: 0 to 23, which represent 00:00 to 23:00 (a total of 24 time points). For example, 1 indicates 01:00. Format description:
Note
If a disk contains a large amount of data and the time required to create a single automatic snapshot exceeds the interval between two time points, the next time point is skipped. For example, you set 09:00, 10:00, 11:00, and 12:00 as the automatic snapshot time points. Because the disk contains a large amount of data, the snapshot creation starts at 09:00 and is completed at 10:20, which takes 80 minutes. The system skips the 10:00 time point and creates the next automatic snapshot at 11:00. |
["0", "1", … "23"] |
| repeatWeekdays |
string |
Yes |
The days of the week on which automatic snapshots are created. Unit: days. The cycle is weekly. Valid values: 1 to 7. For example, 1 indicates Monday. Format description:
|
["1","2"] |
| retentionDays |
integer |
Yes |
The retention period of automatic snapshots. Unit: days. Valid values:
Default value: -1. |
30 |
| EnableCrossRegionCopy |
boolean |
No |
Specifies whether to allow automatic cross-region replication.
|
false |
| TargetCopyRegions |
string |
No |
The destination region to which snapshots are replicated. You can specify one destination region. |
["cn-hangzhou"] |
| StorageLocationArn |
string |
No |
Note
This parameter is not publicly available. |
null |
| CopiedSnapshotsRetentionDays |
integer |
No |
The retention period of cross-region snapshot replicas. Unit: days. Valid values:
Default value: -1. |
30 |
| CopyEncryptionConfiguration |
object |
No |
The backup encryption parameters for snapshot geo-redundancy. |
|
| Encrypted |
boolean |
No |
Specifies whether to enable encryption for cross-region snapshot backup. Valid values:
Default value: false. |
false |
| KMSKeyId |
string |
No |
The key ID of the KMS key used for cross-region encrypted snapshot backup. |
0e478b7a-4262-4802-b8cb-00d3fb40826X |
| Arn |
array<object> |
No |
Note
This parameter is not publicly available. |
|
|
object |
No |
|||
| RoleType |
string |
No |
Note
This parameter is not publicly available. |
hide |
| Rolearn |
string |
No |
Note
This parameter is not publicly available. |
hide |
| AssumeRoleFor |
integer |
No |
Note
This parameter is not publicly available. |
1000000000 |
| ResourceGroupId |
string |
No |
The resource group ID. |
rg-aek2kkmhmhs**** |
| Tag |
array<object> |
No |
The tags of the automatic snapshot policy. |
|
|
object |
No |
|||
| Key |
string |
No |
The tag key of the automatic snapshot policy. Valid values of N: 1 to 20. The tag key cannot be an empty string. The tag key can be up to 128 characters in length and cannot start with aliyun or acs:. The tag key cannot contain http:// or https://. |
TestKey |
| Value |
string |
No |
The tag value of the automatic snapshot policy. Valid values of N: 1 to 20. The tag value can be an empty string. The tag value can be up to 128 characters in length and cannot start with acs:. The tag value cannot contain http:// or https://. |
TestValue |
| AssociationType |
string |
No |
The association type between the automatic snapshot policy and target resources. Valid values: ● AssociatedWithDisk: associated with disks. ● AssociatedWithInstanceTag: associated with instance tags. Default value: AssociatedWithDisk. |
AssociatedWithDisk |
| TargetTags |
array<object> |
No |
The list of target resource tags. The automatic snapshot policy matches target resources based on tags. When AssociationType is set to AssociatedWithInstanceTag, this parameter is required. |
|
|
object |
No |
The target resource tag. |
||
| Key |
string |
No |
The tag key. Valid values of N: 1 to 10. The tag key cannot be an empty string. The tag key can be up to 128 characters in length and cannot start with aliyun or acs:. The tag key cannot contain http:// or https://. |
|
| Value |
string |
No |
The tag value. Valid values of N: 1 to 10. The tag value can be up to 128 characters in length and cannot contain http:// or https://. Note: If you pass in an empty or empty string value, it indicates any value. |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| AutoSnapshotPolicyId |
string |
The ID of the automatic snapshot policy. |
sp-bp12m37ccmxvbmi5**** |
| RequestId |
string |
The request ID. |
473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E |
Examples
Success response
JSON format
{
"AutoSnapshotPolicyId": "sp-bp12m37ccmxvbmi5****",
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}
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 operation is not supported by the current disk category. |
| 400 | InvalidSnapshotPolicyName.Malformed | The specified autoSnapshotPolicyName is malformed. | |
| 400 | Duplicate.TagKey | The Tag.N.Key contain duplicate key. | The specified tag key already exists. Tag keys must be unique. |
| 400 | InvalidTagKey.Malformed | The specified Tag.n.Key is not valid. | The specified Tag.N.Key parameter is invalid. |
| 400 | InvalidTagValue.Malformed | The specified Tag.n.Value is not valid. | The specified tag value is invalid. |
| 400 | InvalidParameter.EncryptedIllegal | The specified parameter Encrypted must be true when kmsKeyId is not empty. | The encryption feature is not enabled after a Key Management Service (KMS) key ID is specified. |
| 400 | InvalidParameter.KmsNotEnabled | Failed to perform this operation because KMS is not activated. | You need to activate KMS key management service. |
| 400 | InvalidParameter.Encrypted.KmsNotEnable | Failed to perform this operation because KMS is not activated. | You need to activate KMS key escrow service. |
| 400 | InvalidParam.EncryptedMismatch | Creating encrypted disks with shared encrypted image requires replacing encryption keys. | You must change the encryption key to create a cloud disk after sharing an encrypted image. |
| 400 | InvalidAssociationType.Malformed | The specified parameter AssociationType is invalid. Please check the valid range for this parameter. | |
| 400 | MissingParameter.TargetTags | When the parameter AssociationType is set to AssociatedWithInstanceTag, the TargetTags parameter is required. | |
| 400 | InvalidTargetTags.NotSupported | When the parameter AssociationType is set to AssociatedWithDisk, the TargetTags parameter is not supported. | |
| 400 | InvalidTargetTagKey.Malformed | The specified TargetTag.n.Key [%s] is not valid. | |
| 400 | InvalidTargetTagValue.Malformed | The specified TargetTag.n.Value [%s] is not valid. | |
| 400 | Duplicate.TargetTagKey | Duplicate keys exist in the specified parameter TargetTags. Please ensure key uniqueness. | |
| 400 | InvalidTargetTag.LimitExceed | The number [%s] of the specified parameter TargetTag exceeds the limit [%s]. | |
| 403 | ParameterInvalid | The specified RegionId parameter is invalid. | The specified region ID is invalid. |
| 403 | AutoSnapshotPolicy.QuotaExceed | The maximum number of automatic snapshot policy has been reached. | |
| 403 | InvalidAccountStatus.NotEnoughBalance | Your account does not have enough balance. | |
| 403 | InvalidAccountStatus.SnapshotServiceUnavailable | Snapshot service has not been opened yet. | The operation is not supported while the snapshot service is not activated. |
| 403 | InvalidParameter.TargetCopyRegions | The specified TargetCopyRegions is invalid. | |
| 403 | InvalidParameter.CopiedSnapshotsRetentionDays | The specified CopiedSnapshotsRetentionDays is invalid. | |
| 403 | InvalidParameter.KMSKeyId.KMSUnauthorized | ECS service does not have permission to access your KMS key. Please verify that the specified KMS key has authorized the ECS service. | |
| 403 | InvalidOperation.KMSKeyIdNotFound | The specified KMSKeyId not found, %s. | The associated KMS encryption key cannot be found. Verify that the KMS encryption key is valid. |
| 403 | Abs.InvalidAction.RegionNotSupport | This region does not support this action. | The operation is not supported in the region. |
| 403 | InvalidParameter.KMSKeyId.CMKNotEnabled | The CMK (Customer Master Key) must be in an active state. | The CMK (Customer Master Key) must be in an active state. |
| 403 | InvalidParameter.KMSKeyId.CMKUnauthorized | The CMK(Customer Master Key) lacks authorization to add tags to the ECS service. | The CMK(Customer Master Key) lacks authorization to add tags to the ECS service. |
| 403 | InvalidStorageLocationArn.Malformed | The specified parameter StorageLocationArn is malformed. | |
| 403 | InvalidOperation.UserNotInWhiteList | The current user is temporarily unable to use this feature. Please submit a ticket for assistance. | |
| 404 | InvalidResourceGroup.NotFound | The ResourceGroup provided does not exist in our records. | The specified resource group does not exist. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.