Updated on 2026-07-21 GMT+08:00

Modifying a Sparse Backup Policy of a DB Instance

Function

This API is used to modify a sparse backup policy of a DB instance.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.
  • If you are using role/policy-based authorization, see Permissions and Supported Actions for details on the required permissions.
  • If you are using identity policy-based authorization, the following identity policy-based permissions are required.

Action

Access Level

Resource Type (*: required)

Condition Key

Alias

Dependencies

rds:instance:modifyBackupPolicy

permission_management

instance

g:EnterpriseProjectId

rds:BackupEnabled

g:ResourceTag/<tag-key>

-

-

Constraints

  • This API is available for RDS for PostgreSQL only.
  • The start_time parameter of a sparse backup policy cannot be set separately. It is the same as that of the basic backup policy of the instance. To obtain the value, see Obtaining an Automated Backup Policy.

URI

  • URI format

    POST /v3/{project_id}/instances/{instance_id}/backups/sparse-policy

  • Parameter description
    Table 1 Parameters

    Parameter

    Mandatory

    Type

    Description

    project_id

    Yes

    String

    Definition

    Project ID of a tenant in a region.

    To obtain the value, see Obtaining a Project ID.

    Constraints

    N/A

    Range

    N/A

    Default Value

    N/A

    instance_id

    Yes

    String

    Definition

    Instance ID.

    You can obtain the value of this parameter from id in Table 4 by calling the API for querying DB instances.

    Constraints

    N/A

    Range

    N/A

    Default Value

    N/A

Request

Table 2 Parameters

Parameter

Mandatory

Type

Description

policies

Yes

Array of Object

Definition

Backup policies.

For details, see Table 3.

Constraints

N/A

Table 3 policies field description

Parameter

Mandatory

Type

Description

id

No

String

Definition

Backup policy ID.

Constraints

A backup policy may be associated with multiple generated backups. Modifying or deleting a policy will take effect for the generated backups associated with this policy. If you shorten the retention period of a policy or delete the policy, the existing full backups associated with this policy can be deleted due to expiration. Check the policy settings carefully.

Range

  • If no ID is specified, a new backup policy will be added.
  • If you enter the ID of an existing backup policy, the backup policy will be modified or deleted. To obtain the ID of a policy, see Querying Sparse Backup Policies.
    • To delete a backup policy, set keep_days to 0 and period to null. In addition, you must specify reserve_backups to indicate whether to retain the automated backups that have been created under this backup policy.
    • To modify a backup policy, you must specify at least either of period and keep_days.

Default Value

N/A

period

No

String

Definition

Backup cycle.

Constraints

This field is a cron expression in the UTC time zone. It works together with start_time. The value of start_time for a sparse backup policy is the same as that for the basic backup policy. To obtain the value of start_time for the basic backup policy of an instance, see Obtaining an Automated Backup Policy.

For example, if the local time zone is UTC+08:00 and the value of start_time queried by an API is 21:00-22:00, the corresponding backup time is 05:00-06:00 local time. If you set the period of a sparse backup policy to 1 * *, the policy will trigger a backup task from 21:00 to 22:00 (UTC) on the 1st day of each month. This corresponds to 05:00 to 06:00 on the 2nd day of each month in your local time zone (UTC+08:00).

This parameter is mandatory when you add a policy.

Range

The value must be a cron expression in the format of "day month week" in the UTC time zone, and the expression must comply with the following rules for weekly, monthly, or yearly policies:

  • Weekly policy

    The day and month must be set to *. The week can be set to a number ranging from 1 to 7 (1 indicates Monday, 2 indicates Tuesday, and so on). You can enter multiple numbers separated by commas (,).

    Example value:

    * * 6 indicates that the task is executed every Saturday.

    * * 1,2,3 indicates that the task is executed every Monday, Tuesday, and Wednesday.

  • Monthly policy

    The month and week must be set to *. The day can be set to a number ranging from 1 to 28 or the special character L (indicating the last day of the month). You can enter multiple numbers separated by commas (,).

    Example value:

    1,2 * * indicates that the task is executed on the 1st and 2nd days of each month.

    L * * indicates that the task is executed on the last day of each month.

  • Yearly policy

    The week must be set to *. The day can be set to a number ranging from 1 to 31, and the month can be set to a number ranging from 1 to 12. The combination of the day and month must be a valid date.

    Example value:

    15 3 * indicates that the task is executed on March 15 every year.

Default Value

N/A

keep_days

No

Integer

Definition

Backup retention days.

Constraints

This parameter is mandatory when you add a policy.

Range

0–3660. The value 0 indicates that the backup policy will be deleted.

Default Value

N/A

reserve_backups

No

Boolean

Definition

Whether to retain the backups when deleting a backup policy.

Constraints

This parameter is valid only when keep_days is set to 0. This parameter is mandatory when you delete a backup policy.

A backup policy may be associated with multiple generated backups. If this parameter is set to false, all backup data associated with the policy will be deleted immediately. Exercise caution when performing this operation.

Range

  • true: The automated backups associated with the backup policy are retained.
  • false: The automated backups associated with the backup policy are deleted immediately when the backup policy is deleted.

Default Value

N/A

Example Request

Modify a sparse backup policy of a DB instance.

POST https://{Endpoint}/v3/0483b6b16e954cb88930a360d2c4e663/instances/a2471f32101d4b57ae2a09f489ac16cein03/backups/sparse-policy

{
    "policies": [
        {
            "period": "3 7 *",
            "keep_days": 7
        }
    ]
}

Response

  • Normal response

    None

  • Example normal response

    None

Status Code

Error Code

For details, see Error Codes.