CreateAutoSnapshotPolicy

更新时间:
复制 MD 格式

Creates an automatic snapshot policy in a specific region. You can specify the schedule 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 automatic snapshot policy. The automatic snapshot policy can be applied to create snapshots for system disks or data disks to back up disk data.

Operation description

Before you call this operation, learn about how to create an automatic snapshot policy.

Take note of the following items:

  • You can create up to 100 automatic snapshot policies per region for a single Alibaba Cloud account. If the maximum number of automatic snapshots for a disk is reached and a new snapshot creation task is created, the system deletes the oldest automatic snapshot of the disk.

  • If the instance to which a disk is attached is being stopped or restarted, the system cannot create snapshots for the disk based on the associated automatic snapshot policy.

  • 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. For more information about the limits on cross-region snapshot replication, see Copy a snapshot.

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.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ecs:CreateAutoSnapshotPolicy

create

*AutoSnapshotPolicy

acs:ecs:{#regionId}:{#accountId}:snapshotpolicy/*

None None

Request parameters

Parameter

Type

Required

Description

Example

regionId

string

Yes

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

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

By default, this parameter is left empty.

TestName

timePoints

string

Yes

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. For example, 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 up to 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.

Note

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 scheduled snapshots to be automatically created at 09:00, 10:00, 11:00, and 12:00. 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. 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.

["0", "1", … "23"]

repeatWeekdays

string

Yes

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"]

retentionDays

integer

Yes

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

EnableCrossRegionCopy

boolean

No

Specifies whether to enable cross-region replication for snapshots.

  • true

  • false

false

TargetCopyRegions

string

No

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

["cn-hangzhou"]

StorageLocationArn

string

No

Note

This parameter is not publicly available.

null

CopiedSnapshotsRetentionDays

integer

No

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

Tag

array<object>

No

The tags to add to the automatic snapshot policy.

object

No

Key

string

No

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

Value

string

No

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

ResourceGroupId

string

No

The resource group ID.

rg-aek2kkmhmhs****

CopyEncryptionConfiguration

object

No

The encryption parameters for cross-region snapshot replication.

Encrypted

boolean

No

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

  • true

  • false

Default value: false.

false

KMSKeyId

string

No

The ID of the Key Management Service (KMS) key used in cross-region snapshot replication and encryption.

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

Response elements

Element

Type

Description

Example

object

AutoSnapshotPolicyId

string

The automatic snapshot policy ID.

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 response

JSON format

{
    "RequestId":"F3CD6886-D8D0-4FEE-B93E-1B73239673DE"
    "AutoSnapshotPolicyId":"p-233e6ylv0"
}

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 wrongly formed.
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.
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 have no right to access your KMS. ECS is not authorized to access your KMS resources.
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 wrongly formed. The format of the specified parameter StorageLocationArn is incorrect.
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.