CreatePolicyV2

Updated at:

Creates a policy.

Operation description

A backup policy records the information required for backups. After a backup policy is executed, a backup job is generated to record the backup progress and results. If the backup job succeeds, a backup snapshot is generated. You can use the backup snapshot to create a restore job.

  • A backup policy supports multiple data sources, including NAS backup, OSS backup, ECS instance backup, ECS File Backup Standard Edition, local file backup, Tablestore backup, and CPFS backup.

  • A backup policy supports only a single backup cycle policy with a fixed time interval.

  • A backup policy can back up data to only one 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 policy name.

Daily local backup + cross-region backup

PolicyType

string

No

The policy type. Valid values:

  • STANDARD: general backup policy. Supports backing up data sources other than ECS instances.

  • UDM_ECS_ONLY: ECS instance backup policy. Supports backing up only ECS instances.

If you do not specify the policy type, 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 policy rules: STANDARD.

  • If no backup vault is specified in the policy rules: UDM_ECS_ONLY.

STANDARD

PolicyDescription

string

No

The policy description.

Back up data at 10:00 AM every day and perform a cross-region backup to Shanghai.

Rules

array<object>

No

The list of policy rules.

array<object>

No

The policy rule.

RuleType

string

Yes

The rule type. Each policy must contain at least one BACKUP rule and exactly one TRANSITION rule. Valid values:

  • BACKUP: backup rule.

  • TRANSITION: lifecycle rule.

  • REPLICATION: replication rule.

  • TAG: tag-based resource association rule.

Valid values:

  • TRANSITION :

    Lifecycle rule.

  • BACKUP :

    Backup rule.

  • REPLICATION :

    Replication rule.

  • SECURITY :

    Security rule.

  • TAG :

    Tag-based resource association rule.

BACKUP

Schedule

string

No

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

  • I|{startTime}|{interval}: executes a backup job at an interval of {interval} starting from {startTime}. For example, I|1631685600|P1D indicates that a backup job is executed every day starting from 14:00:00 on September 15, 2021.

    • startTime: the start time of the backup. The value is a UNIX timestamp in seconds.

    • interval: the ISO 8601 time interval. For example, PT1H indicates an interval of one hour, and P1D indicates an interval of one day.

  • C|{startTime}|{crontab}: executes a backup job based on the {crontab} expression starting from {startTime}. For example, C|1631685600|0 0 2 ? * 3,5,7 indicates that a backup job is executed at 02:00:00 every Tuesday, Thursday, and Saturday starting from 14:00:00 on September 15, 2021.

    • startTime: the start time of the backup. The value is a UNIX timestamp in seconds.

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

Backup jobs that missed their scheduled time are not compensated. If the previous backup job is not completed, the next backup job is not triggered.

I|1648647166|P1D

BackupType

string

No

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

Valid values:

  • ARCHIVE_BY_SEARCH :

    Archive by search result.

  • COMPLETE :

    Full backup.

  • LOG :

    Log backup.

  • ARCHIVE :

    Archive.

  • DIFFERENTIAL :

    Differential backup.

  • INDEX :

    Index.

  • INCREMENTAL :

    Incremental backup.

COMPLETE

Retention

integer

No

This parameter is required only when RuleType is set to BACKUP, TRANSITION, or REPLICATION.

  • If RuleType is set to BACKUP: the retention period of the backup. The priority of this parameter is lower than that of the Retention parameter in a rule where RuleType is set to TRANSITION. Minimum value: 1. Maximum value: 364635. Unit: days.

  • If RuleType is set to TRANSITION: the retention period of the backup. Minimum value: 1. Maximum value: 364635. Unit: days.

  • If RuleType is set to REPLICATION: the retention period of the cross-region backup. Minimum value: 1. Maximum value: 364635. Unit: days.

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

ArchiveDays

integer

No

This parameter is required only when RuleType is set to TRANSITION. The number of days after which a backup is automatically transitioned to the archive tier. Backups must be retained in the standard tier for at least 30 days and in the archive tier for at least 60 days after the transition. Unit: days.

90

RetentionRules

array<object>

No

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

object

No

The special retention rule.

AdvancedRetentionType

string

No

The type of the special retention rule. Valid values:

  • DAILY: daily backup.

  • WEEKLY: weekly backup.

  • MONTHLY: monthly backup.

  • YEARLY: yearly backup.

YEARLY

WhichSnapshot

integer

No

The sequence number of the backup to which the rule applies. Currently, only the first backup is supported. Set the value to 1.

1

Retention

integer

No

The special retention period of the backup. Minimum value: 1. Unit: days.

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 retain at least one backup version. Valid values:

  • 0: Do not retain.

  • 1: Retain.

1

Immutable

boolean

No

This parameter is required only when PolicyType is set to UDM_ECS_ONLY and RuleType is set to SECURITY. Specifies whether to enable backup lock.

true

DataSourceFilters

array<object>

No

This parameter is required only when RuleType is set to TAG. The data source filtering rules.

array<object>

No

SourceType

string

No

The data source type. Valid values:

  • UDM_ECS: ECS instance backup. This data source type is supported only when PolicyType is set to UDM_ECS_ONLY.

  • OSS: OSS backup. This data source type is supported only when PolicyType is set to STANDARD.

  • NAS: Alibaba Cloud NAS backup. This data source type is supported only when PolicyType is set to STANDARD.

  • ECS_FILE: ECS File Backup Standard Edition. This data source type is supported only when PolicyType is set to STANDARD.

  • OTS: Tablestore backup. This data source type is supported only when PolicyType is set to STANDARD.

UDM_ECS

DataSourceIds deprecated

array

No

[Deprecated]

deprecated

string

No

[Deprecated]

**[Deprecated]**

AccountScope

string

No

The account scope to which the policy applies.

SPECIFIED_ACCOUNT

Accounts

array<object>

No

The list of account information in the data source filtering conditions.

object

No

CrossAccountType

string

No

The account association type, which is used to distinguish between the current account and cross-account scenarios.

CROSS_ACCOUNT_BY_RD

CrossAccountUserId

integer

No

The Alibaba Cloud account ID of the account that owns the resources to be backed up.

1234567890123456

CrossAccountRoleName

string

No

The name of the RAM role created in the account that owns the resources to be backed up.

hbrcrossrole

TagFilters

array<object>

No

This parameter is required only when RuleType is set to TAG. The resource tag filtering rules.

object

No

Key

string

No

The tag key.

env

Value

string

No

The tag value. An empty value indicates any value.

prod

Operator

string

No

The tag matching rule. Valid values:

  • EQUAL: matches both the tag key and the 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 is successful. Valid values:

  • true: The request is successful.

  • false: The request fails.

true

Code

string

The return code. A value of 200 indicates success.

200

Message

string

The return message. If the request is successful, "successful" is returned. If an error occurs, the corresponding error message is returned.

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.