Updated on 2025-10-24 GMT+08:00

Setting an Automated Backup Policy

Function

This API is used to set an automated backup policy.

URI

  • URI format

    PUT /v3/{project_id}/instances/{instance_id}/backups/policy

  • URI example

    https://dds.ap-southeast-1.myhuaweicloud.com/v3/97b026aa9cc4417888c14c84a1ad9860/instances/cc6345c64cec47499182467ea0dd432ain02/backups/policy

Table 1 Path parameters

Name

Mandatory

Type

IN

Description

project_id

Yes

string

path

Explanation:

Project ID of a tenant in a region. To obtain the project ID, see Obtaining a Project ID.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

instance_id

Yes

string

path

Explanation:

Instance ID, which can be obtained by calling the API described in Querying Instances and Details. If you do not have an instance, call the API described in Creating a DB Instance to create one.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

Request Parameters

Table 2 Request header parameters

Name

Mandatory

Type

IN

Description

X-Auth-Token

Yes

string

header

Definition

User token obtained from IAM. For details, see Authentication.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 3 Request body parameters

Name

Mandatory

Type

Description

backup_policy

Yes

Object

Definition

The backup policy object, including the backup retention period (days) and start time. For more information, see Table 4.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 4 Data structure description of the backup_policy field

Name

Mandatory

Type

Description

keep_days

No

String

Definition

The number of days to retain the generated backup files.

Constraints

Either keep_days or enable_incremental_backup must be transferred.

Range

0–732 If the value is 0, backup policies are disabled, including automated and incremental backup policies.

Default Value

N/A

start_time

No

String

Definition

The backup time window. Automated backups will be triggered during the backup time window.

Constraints

This parameter is mandatory if the automated backup policy is enabled. If the policy is disabled, you do not need to transfer this parameter.

Range

The value must be a valid value in the "hh:mm-HH:MM" format. The current time is in the UTC format.

  • The HH value must be 1 greater than the hh value.
  • The values of mm and MM must be the same and must be set to 00.

Example value:

23:00-00:00

Default Value

N/A

period

No

String

Definition

The backup cycle configuration. Data will be automatically backed up on the selected days every week.

Constraints

  • This parameter is not transferred if the retention period is set to 0.
  • If you set the retention period to 1 to 6 days, data is automatically backed up each day of the week. Set the parameter value to 1,2,3,4,5,6,7.
  • If you set the retention period to 7 to 732 days, select at least one day of the week for the backup cycle. Example value: 1,2,3,4

Range

The value is a list of digits separated by commas (,). Each digit indicates a day of the week.

Default Value

N/A

enable_incremental_backup

No

Boolean

Definition

Whether to enable incremental backup. If this parameter is not transferred, the incremental backup status remains unchanged. After incremental backup is enabled, the system automatically performs an incremental backup.

Constraints

N/A

Range

  • false: Incremental backup is disabled. If incremental backup is disabled, the previous incremental backups will be deleted.
  • true: Incremental backup is enabled. After incremental backup is enabled, a full backup is triggered.

Default Value

N/A

Response Parameters

None

Example Requests

  • Enabling or modifying the automated backup policy and enabling the incremental backup policy:
    PUT https://{endpoint}/v3/054e292c9880d4992f02c0196d3ea468/instances/3d39c18788b54a919bab633874c159dfin02/backups/policy 
      
     { 
       "backup_policy" : { 
         "keep_days" : 9, 
         "start_time" : "08:15-09:15", 
         "period" : "1,4,5,6,7", 
         "enable_incremental_backup" : true 
       } 
     }
  • Enabling or modifying the automated backup policy and disabling the incremental backup policy:
    PUT https://{endpoint}/v3/054e292c9880d4992f02c0196d3ea468/instances/3d39c18788b54a919bab633874c159dfin02/backups/policy 
      
     { 
       "backup_policy" : { 
         "keep_days" : 9, 
         "start_time" : "08:15-09:15", 
         "period" : "1,4,5,6,7", 
         "enable_incremental_backup" : false 
       } 
     }
  • Enabling or modifying the automated backup policy only, and retaining the status of the incremental backup policy:
    PUT https://{endpoint}/v3/054e292c9880d4992f02c0196d3ea468/instances/3d39c18788b54a919bab633874c159dfin02/backups/policy 
      
     { 
       "backup_policy" : { 
         "keep_days" : 9, 
         "start_time" : "08:15-09:15", 
         "period" : "1,4,5,6,7" 
       } 
     }
  • Enabling the incremental backup policy: This request can be delivered only when the automated full backup policy is enabled. The same rule applies to disabling the incremental backup policy.
    PUT https://{endpoint}/v3/054e292c9880d4992f02c0196d3ea468/instances/3d39c18788b54a919bab633874c159dfin02/backups/policy 
      
     { 
       "backup_policy" : { 
         "enable_incremental_backup" : true 
       } 
     }
  • Disabling backup policies, including automated and incremental backup policies:
    PUT https://{endpoint}/v3/054e292c9880d4992f02c0196d3ea468/instances/3d39c18788b54a919bab633874c159dfin02/backups/policy 
      
     { 
       "backup_policy" : { 
         "keep_days" : 0 
       } 
     }

Example Responses

None

Status Code

For more information, see Status Code.

Error Code

For more information, see Error Code.