All Products
Search
Document Center

Elastic Compute Service:CreateAutoSnapshotPolicy

Last Updated:Dec 03, 2024

Creates an automatic snapshot policy in a specific region. Automatic snapshot policies allow Elastic Compute Service (ECS) to create snapshots for cloud disks on a regular basis to back up data. The policies can be applied to both system disks and data disks. If cross-region snapshot replication is enabled and no encryption parameters are configured, encrypted snapshots are copied to the destination region and snapshot copies are encrypted by using the service key of the destination region.

Operation description

Usage notes

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 whether to enable cross-region replication for the snapshots in the policy to meet your diverse data backup requirements. After the automatic snapshot policy is created, call the ApplyAutoSnapshotPolicy operation to apply the policy to disks. If you want to modify the automatic snapshot policy, call the ModifyAutoSnapshotPolicyEx operation.

Take note of the following items:

  • You can create up to 100 automatic snapshot policies per 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 to complete because the disk contains a large volume of data and ends at 10:20:00. In this case, the system does not create a snapshot at 10:00, but creates a snapshot at 11:00.
  • For information about how to copy a snapshot from one region to another region, see the "Background information" section in Copy a snapshot.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
ecs:CreateAutoSnapshotPolicycreate
*AutoSnapshotPolicy
acs:ecs:{#regionId}:{#accountId}:snapshotpolicy/*
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
regionIdstringYes

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.

cn-hangzhou
autoSnapshotPolicyNamestringNo

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 letters, digits, colons (:), underscores (_), and hyphens (-).

By default, this parameter is left empty.

TestName
timePointsstringYes

The points in time of the day at which to create automatic snapshots. The time must be in UTC+8. Unit: hours. Valid values: 0 to 23, which correspond to the 24 on-the-hour points in time from 00:00:00 to 23:00:00. 1 indicates 01:00:00. Format description:

  • Set this parameter to a JSON-formatted array. For example, a value of ["1"] specifies automatic snapshots to be created at 01:00:00.
  • To schedule multiple automatic snapshots to be created in a day, you can specify multiple values. Separate the values with commas (,). You can specify a maximum of 24 points in time. For example, a value of ["1","3","5"] specifies automatic snapshots to be created at 01:00:00, 03:00:00, and 05:00:00.
["0", "1", … "23"]
repeatWeekdaysstringYes

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. Format description:

  • Set this parameter to a JSON-formatted array. For example, a value of ["1"] specifies automatic snapshots to be created every Monday.
  • To schedule multiple automatic snapshots to be created in a week, you can specify multiple values. Separate the values with commas (,). You can specify a maximum of seven days. For example, a value of ["1","3","5"] specifies automatic snapshots to be created every Monday, Wednesday, and Friday.
["1","2"]
retentionDaysintegerYes

The retention period of the automatic snapshot. Unit: days. Valid values:

  • -1: The automatic snapshot is retained until it is deleted.
  • 1 to 65535: The automatic snapshot is retained for the specified number of days. After the retention period of the automatic snapshot expires, the automatic snapshot is automatically deleted.

Default value: -1.

30
EnableCrossRegionCopybooleanNo

Specifies whether to enable cross-region replication for snapshots.

  • true
  • false
false
TargetCopyRegionsstringNo

The destination region to which to copy the snapshot. You can specify only a single destination region.

["cn-hangzhou"]
StorageLocationArnstringNo
Note This parameter is not publicly available.
null
CopiedSnapshotsRetentionDaysintegerNo

The retention period of the snapshot copy in the destination region. Unit: days. Valid values:

  • -1: The snapshot copy is retained until it is deleted.
  • 1 to 65535: The snapshot copy is retained for the specified number of days. After the retention period of the snapshot copy expires, the snapshot copy is automatically deleted.

Default value: -1.

30
Tagarray<object>No

The tags to add to the automatic snapshot policy.

objectNo
KeystringNo

The key of tag N to add to 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 contain http:// or https://. The tag key cannot start with acs: or aliyun.

TestKey
ValuestringNo

The value of tag N to add to 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 contain http:// or https://. The tag value cannot start with acs:.

TestValue
ResourceGroupIdstringNo

The resource group ID.

rg-aek2kkmhmhs****
CopyEncryptionConfigurationobjectNo

The encryption parameters for cross-region snapshot replication.

EncryptedbooleanNo

Specifies whether to enable cross-region snapshot replication and encryption. Valid values:

  • true
  • false

Default value: false.

false
KMSKeyIdstringNo

The ID of the KMS key used in cross-region snapshot replication and encryption.

0e478b7a-4262-4802-b8cb-00d3fb40826X
Arnarray<object>No

This parameter is not publicly available.

objectNo
RoleTypestringNo

This parameter is not publicly available.

hide
RolearnstringNo

This parameter is not publicly available.

hide
AssumeRoleForlongNo

This parameter is not publicly available.

1000000000

Response parameters

ParameterTypeDescriptionExample
object
AutoSnapshotPolicyIdstring

The automatic snapshot policy ID.

sp-bp12m37ccmxvbmi5****
RequestIdstring

The request ID.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

Examples

Sample success responses

JSONformat

{
  "AutoSnapshotPolicyId": "sp-bp12m37ccmxvbmi5****",
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}

Error codes

HTTP status codeError codeError messageDescription
400DiskCategory.OperationNotSupportedThe type of the specified disk does not support creating a snapshot.The operation is not supported by the current disk category.
400InvalidSnapshotPolicyName.MalformedThe specified autoSnapshotPolicyName is wrongly formed.-
400Duplicate.TagKeyThe Tag.N.Key contain duplicate key.The specified tag key already exists. Tag keys must be unique.
400InvalidTagKey.MalformedThe specified Tag.n.Key is not valid.The specified Tag.N.Key parameter is invalid.
400InvalidTagValue.MalformedThe specified Tag.n.Value is not valid.The specified tag value is invalid.
400InvalidParameter.EncryptedIllegalThe 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.
400InvalidParameter.KMSKeyId.CMKNotEnabledThe CMK needs to be enabled.The customer master key (CMK) is not enabled when KMSKeyId is specified for an encrypted disk. You can call the DescribeKey operation of KMS to query information about the specified CMK.
400InvalidParameter.KmsNotEnabledFailed to perform this operation because KMS is not activated.You need to activate KMS key management service.
400InvalidParameter.Encrypted.KmsNotEnableFailed to perform this operation because KMS is not activated.You need to activate KMS key escrow service.
400InvalidParam.EncryptedMismatchCreating 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.
403ParameterInvalidThe specified RegionId parameter is invalid.The specified region ID is invalid.
403ParameterInvalidThe specified RepeatWeekDays parameter is invalid.The specified RepeatWeekdays parameter is invalid.
403ParameterInvalidThe specified TimePoints parameter is invalid.The specified TimePoints parameter is invalid.
403ParameterInvalidThe specified RetentionDays parameter is invalid.The specified RetentionDays parameter is invalid.
403AutoSnapshotPolicy.QuotaExceedThe maximum number of automatic snapshot policy has been reached.The maximum number of automatic snapshot policy is exceeded.
403InvalidAccountStatus.NotEnoughBalanceYour account does not have enough balance.Your account balance is insufficient. Add funds to your account and try again.
403InvalidAccountStatus.SnapshotServiceUnavailableSnapshot service has not been opened yet.The operation is not supported while the snapshot service is not activated.
403InvalidParameter.TargetCopyRegionsThe specified TargetCopyRegions is invalid.-
403InvalidParameter.CopiedSnapshotsRetentionDaysThe specified CopiedSnapshotsRetentionDays is invalid.-
403InvalidParameter.KMSKeyId.CMKUnauthorizedThe CMK needs to be added ECS tag.-
403InvalidParameter.KMSKeyId.KMSUnauthorizedECS service have no right to access your KMS.ECS is not authorized to access your KMS resources.
403InvalidOperation.KMSKeyIdNotFoundThe specified KMSKeyId not found, %s.The associated KMS encryption key cannot be found. Verify that the KMS encryption key is valid.
403Abs.InvalidAction.RegionNotSupportThis region does not support this action.The operation is not supported in the region.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2024-12-02API Description Update. The API operation is not deprecated.. The Error code has changedView Change Details
2024-03-21The Error code has changedView Change Details
2024-02-28The Error code has changed. The request parameters of the API has changedView Change Details