All Products
Search
Document Center

Cloud Backup:CreatePolicyV2

Last Updated:Mar 30, 2026

Create a policy.

Operation description

A backup policy configures your backups. When a policy runs, it initiates a backup job to track its progress and outcome. A successful backup job creates a snapshot that you can use to create a restore job.

  • A backup policy supports multiple data sources, including NAS backup, OSS backup, ECS instance backup, ECS file backup, on-premises file backup, Tablestore backup, and CPFS backup.

  • A backup policy can have only one backup schedule with a fixed interval.

  • A backup policy backs up data to a single backup vault.

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

hbr:CreatePolicyV2

create

*All Resource

*

None

None

Request parameters

Parameter

Type

Required

Description

Example

PolicyName

string

No

The name of the backup policy.

Daily local backup + cross-region backup

PolicyType

string

No

The type of the backup policy. Valid values:

  • STANDARD: A standard backup policy. It supports data sources other than ECS instance backup.

  • UDM_ECS_ONLY: A backup policy that supports only ECS instance backups.

If you do not specify this parameter, Cloud Backup automatically sets the policy type based on whether a backup vault is specified in the policy rules:

  • If a backup vault is specified in the rules, the policy type is set to STANDARD.

  • If no backup vault is specified in the rules, the policy type is set to UDM_ECS_ONLY.

STANDARD

PolicyDescription

string

No

The description of the backup policy.

Back up once daily at 10:00 AM, with cross-region backup to Shanghai.

Rules

array<object>

No

The list of policy rules.

array<object>

No

A policy rule.

RuleType

string

Yes

The type of the rule. Each policy requires at least one BACKUP rule and exactly one TRANSITION rule. Valid values:

  • BACKUP: A backup rule.

  • TRANSITION: A lifecycle rule.

  • REPLICATION: A replication rule.

  • TAG: A rule to associate data sources with the policy by using tags.

BACKUP

Schedule

string

No

This parameter is required only when RuleType is set to BACKUP. The backup schedule. Valid formats:

  • I|{startTime}|{interval}: Runs a backup job at the specified interval starting from {startTime}. For example, I|1631685600|P1D runs a backup job every day, starting from 2021-09-15 14:00:00.

    • startTime: The backup start time in UNIX time, in seconds.

    • interval: The backup interval in ISO 8601 format. For example, PT1H specifies an interval of 1 hour. P1D specifies an interval of 1 day.

  • C|{startTime}|{crontab}: Runs a backup job based on the specified crontab expression starting from {startTime}. For example, C|1631685600|0 0 2 ? * 3,5,7 runs a backup job at 02:00:00 on every Tuesday, Thursday, and Saturday, starting from 2021-09-15 14:00:00.

    • startTime: The backup start time in UNIX time, in seconds.

    • crontab: A crontab expression. For example, 0 0 2 ? * 3,5,7 specifies 02:00:00 on every Tuesday, Thursday, and Saturday.

Missed backup jobs are not run retroactively. If a backup job is still running, the next scheduled job is not triggered.

I|1648647166|P1D

BackupType

string

No

This parameter is required only when RuleType is set to BACKUP. The backup type. The value COMPLETE specifies a full backup.

COMPLETE

Retention

integer

No

This parameter is required only when RuleType is set to BACKUP, TRANSITION, or REPLICATION. The retention period in days.

  • If RuleType is BACKUP: The backup retention period. A Retention parameter in a TRANSITION rule overrides this setting. The value must be between 1 and 364635.

  • If RuleType is TRANSITION: The backup retention period. The value must be between 1 and 364635.

  • If RuleType is REPLICATION: The retention period for cross-region backups. The value must be between 1 and 364635.

7

ReplicationRegionId

string

No

This parameter is required only when RuleType is set to REPLICATION. The ID of the destination region for replication.

cn-shanghai

RetentionRules

array<object>

No

This parameter is required only when RuleType is set to TRANSITION. The advanced retention rules.

object

No

An advanced retention rule.

AdvancedRetentionType

string

No

The type of the advanced retention rule. Valid values:

  • DAILY: Daily backups.

  • WEEKLY: Weekly backups.

  • MONTHLY: Monthly backups.

  • YEARLY: Yearly backups.

YEARLY

WhichSnapshot

integer

No

The ordinal number of the backup to keep based on the AdvancedRetentionType. For example, a value of 1 indicates the first backup. Currently, only a value of 1 is supported.

1

Retention

integer

No

The retention period in days for this advanced rule. The minimum value is 1.

730

VaultId

string

No

This parameter is required only when RuleType is set to BACKUP. The ID of the backup vault.

v-0001************aseg

KeepLatestSnapshots

integer

No

Specifies whether to permanently retain at least one backup version. Valid values:

  • 0: Do not retain.

  • 1: Retain.

1

Immutable

boolean

No

Valid only when PolicyType is set to UDM_ECS_ONLY. Specifies whether to enable backup lock for the backups.

true

DataSourceFilters

array<object>

No

This parameter is required only when RuleType is set to TAG. The filter rules for data sources.

object

No

SourceType

string

No

The type of the data source. Valid values:

  • UDM_ECS: ECS instance backup. Supported only when PolicyType is set to UDM_ECS_ONLY.

  • OSS: OSS backup. Supported only when PolicyType is set to STANDARD.

  • NAS: NAS backup. Supported only when PolicyType is set to STANDARD.

  • ECS_FILE: ECS file backup. Supported only when PolicyType is set to STANDARD.

  • OTS: Tablestore backup. Supported only when PolicyType is set to STANDARD.

UDM_ECS

DataSourceIds

array

No

This parameter is deprecated.

string

No

This parameter is deprecated.

Deprecated.

TagFilters

array<object>

No

This parameter is required only when RuleType is set to TAG. The filter rules for resource tags.

object

No

Key

string

No

The tag key.

env

Value

string

No

The tag value. If you leave this parameter empty, the filter matches any value for the specified tag key.

prod

Operator

string

No

The operator for matching tags. Valid values:

  • EQUAL: Matches both the tag key and tag value.

  • NOT: Matches the tag key but not the tag value.

EQUAL

Response elements

Element

Type

Description

Example

object

CreatePolicyResponse

Success

boolean

Indicates whether the request succeeded. Valid values:

  • true: The request succeeded.

  • false: The request failed.

true

Code

string

The return code. A value of 200 indicates that the request succeeded.

200

Message

string

The response message. successful is returned for a successful request. An error message is returned for a failed request.

successful

RequestId

string

The request ID.

EEC65C22-2152-5E31-8AD6-D6CBF1BFF49F

PolicyId

string

The policy ID.

po-000000zemnuyx2li3y9y

Examples

Success response

JSON format

{
  "Success": true,
  "Code": "200",
  "Message": "successful",
  "RequestId": "EEC65C22-2152-5E31-8AD6-D6CBF1BFF49F",
  "PolicyId": "po-000000zemnuyx2li3y9y"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.