全部产品
Search
文档中心

云数据库 RDS:ModifyBackupPolicy - 修改实例备份策略

更新时间:Jun 30, 2026

该接口用于修改RDS实例的备份策略设置。

接口说明

适用引擎

  • RDS MySQL

  • RDS PostgreSQL

  • RDS SQL Server

  • RDS MariaDB

相关功能文档

重要 使用该接口前,请仔细阅读功能文档,确保完全了解使用接口的前提条件及使用后造成的影响后,再进行操作。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

调试

授权信息

下表是API对应的授权信息,可以在RAM权限策略语句的Action元素中使用,用来给RAM用户或RAM角色授予调用此API的权限。具体说明如下:

  • 操作:是指具体的权限点。

  • 访问级别:是指每个操作的访问级别,取值为写入(Write)、读取(Read)或列出(List)。

  • 资源类型:是指操作中支持授权的资源类型。具体说明如下:

    • 对于必选的资源类型,用前面加 * 表示。

    • 对于不支持资源级授权的操作,用全部资源表示。

  • 条件关键字:是指云产品自身定义的条件关键字。

  • 关联操作:是指成功执行操作所需要的其他权限。操作者必须同时具备关联操作的权限,操作才能成功。

操作

访问级别

资源类型

条件关键字

关联操作

rds:ModifyBackupPolicy

update

*DBInstance

acs:rds:{#regionId}:{#accountId}:dbinstance/{#dbinstanceId}

  • rds:ResourceTag
  • rds:EnableBackupLog
  • rds:BackupLog

请求参数

名称

类型

必填

描述

示例值

DBInstanceId

string

实例 ID。可调用 DescribeDBInstances 获取。

rm-uf6wjk5****

BackupPolicyMode

string

备份类型,取值:

  • DataBackupPolicy:数据备份

  • LogBackupPolicy:日志备份

DataBackupPolicy

PreferredBackupTime

string

执行备份任务的时间。格式:HH:mmZ-HH:mmZ(UTC 时间)。

说明
  • BackupPolicyModeDataBackupPolicy 时,该参数必传。

  • 仅在 BackupPolicyMode 参数为 DataBackupPolicy 时生效。

00:00Z-01:00Z

PreferredBackupPeriod

string

备份周期。至少需要指定 2 天,多个取值用英文逗号(,)隔开。取值:

  • Monday:周一

  • Tuesday:周二

  • Wednesday:周三

  • Thursday:周四

  • Friday:周五

  • Saturday:周六

  • Sunday:周日

说明
  • BackupInterval 参数共同决定备份策略。例如:本参数指定周六周日备份,BackupInterval 参数指定 30 分钟,则在每周的周六和周日每隔 30 分钟执行一次备份。

  • BackupPolicyMode 参数为 DataBackupPolicy 时,该参数必传。

  • 仅在 BackupPolicyMode 参数为 DataBackupPolicy 时生效。

Monday

BackupRetentionPeriod

string

数据备份保留天数,取值:7~730

说明
  • BackupPolicyModeDataBackupPolicy 时,该参数必传。

  • 仅在 BackupPolicyMode 参数为 DataBackupPolicy 时生效。

7

BackupLog

string

是否开启日志备份。取值:

  • Enable:开启。

  • Disabled:关闭。

对于 SQL Server 实例,日志备份默认开启,无法关闭,但您可以修改日志备份频率,具体如下:

  • 日志备份频率为每 5 分钟一次:BackupLog 设置为 Enable,LogBackupFrequency 为空(无需传值)。更多详情,请参见 5 分钟日志备份功能该配置不支持在设置了优先备库(BackupPriority 为 1)时使用,否则将会报错。

  • 日志备份频率为每 30 分钟一次:BackupLog 为空(无需传值),LogBackupFrequency 设置为 LogInterval。

  • 日志备份频率为与数据备份一致:BackupLog 为空(无需传值),LogBackupFrequency 为空(无需传值)。

说明

该参数仅在 BackupPolicyModeDataBackupPolicy 时生效,用于开启或关闭日志备份。

Enable

LogBackupRetentionPeriod

string

日志备份保留天数。取值:7~730,且不大于数据备份保留天数。

说明
  • 当开启日志备份时,可设置日志备份文件的保留天数,目前仅支持 MySQL 和 PostgreSQL 实例设置该值。

  • BackupPolicyMode 参数为 DataBackupPolicyLogBackupPolicy 时都适用。

7

EnableBackupLog

string

MySQLPostgreSQLMariaDB 实例是否开启日志备份。取值:

  • True1:开启。

  • False0:关闭。

说明
  • SQL Server实例日志备份默认开启,无法关闭。因此 SQL Server 实例无需关注此参数。

  • 该参数仅在 BackupPolicyModeLogBackupPolicy 时生效,用于开启或关闭日志备份。

1

EnablePitrProtection

boolean

MySQL 实例是否开启任意时间点恢复。取值:

  • True:开启

  • False:关闭

说明

仅在 BackupPolicyMode 参数为 DataBackupPolicyBackupLogEnable 时生效。功能详情,请参见设置任意时间点恢复策略

True

LocalLogRetentionHours

string

MySQL 实例日志备份本地保留小时数。取值:0~7*24,0 表示不保留。

说明

该参数仅在 BackupPolicyModeLogBackupPolicy 时生效,且此时该参数必传。

18

LocalLogRetentionSpace

string

MySQL 实例本地日志最大循环空间使用率,超出后,则从最早的 Binlog 开始清理,直到空间使用率低于该比例。取值:0~50。默认不修改。

说明

该参数仅在 BackupPolicyModeLogBackupPolicy 时生效,且此时该参数必传。

30

HighSpaceUsageProtection

string

MySQL 实例使用空间大于 80%,或者剩余空间小于 5 GB 时,是否无条件清理 Binlog。取值:Enable | Disable。默认不修改。

说明

该参数仅在 BackupPolicyModeLogBackupPolicy 时生效,且此时该参数必传。

Enable

LogBackupFrequency

string

SQL Server实例的日志备份频率,取值:

  • LogInterval每 30 分钟

  • (无需传值):每 5 分钟备份一次或与数据备份一致

说明

该参数仅在 BackupPolicyMode 参数为 DataBackupPolicy 时生效。

LogInterval

CompressType

string

备份压缩方式。取值:

  • 0:不压缩。

  • 1:zlib 压缩,格式为 tar.gz。

  • 2:并行 zlib 压缩。

  • 4:quicklz 压缩,格式为 xb.gz。仅适用于 MySQL 5.6/5.7,此备份压缩方式可用于单库单表恢复

  • 8:quicklz 压缩,格式为 xb.gz。仅适用于 MySQL 8.0。暂不支持单库单表恢复。

说明

仅在 BackupPolicyMode 参数为 DataBackupPolicy 时生效。

4

ArchiveBackupRetentionPeriod

string

归档备份的保留天数。默认为 0,表示未开启归档备份。取值:30~1095

说明

仅在 BackupPolicyMode 参数为 DataBackupPolicy 时生效。

365

ArchiveBackupKeepPolicy

string

归档备份的保留周期,该周期内能保存的备份个数由 ArchiveBackupKeepCount 决定。默认为 0。取值:

  • ByMonth:月

  • ByWeek:周

  • KeepAll:全部保留

说明

仅在 BackupPolicyMode 参数为 DataBackupPolicy 时生效。

ByMonth

ArchiveBackupKeepCount

integer

归档备份的保留个数。默认为 1。取值:

  • ArchiveBackupKeepPolicyByMonth 时,取值为 1~31

  • ArchiveBackupKeepPolicyByWeek 时,取值为 1~7

说明
  • ArchiveBackupKeepPolicyKeepAll 时,本参数无需传入。

  • 仅在 BackupPolicyMode 参数为 DataBackupPolicy 时生效。

1

ReleasedKeepPolicy

string

MySQL 已删除实例的归档备份保留策略。取值:

  • None:不保留

  • Lastest:保留最后一个

  • All:全部保留

说明
  • 仅在 BackupPolicyMode 参数为 DataBackupPolicy 时生效。

  • 2024 年 02 月 01 日及之后新购的 RDS MySQL 云盘实例 ReleasedKeepPolicy 默认值为 Lastest;高性能本地盘实例默认值为 None。功能详情,请参见已删除实例备份

None

LogBackupLocalRetentionNumber

integer

本地 Binlog 保留个数。默认为 60。取值:6~100

说明
  • 仅在 BackupPolicyMode 参数为 LogBackupPolicy 时生效。

  • 如果实例类型为 MySQL,可以传入-1,即不限制本地 Binlog 的保留个数。

60

Category

string

是否开启秒级备份。取值:

  • Flash:开启

  • Standard:关闭

说明

仅在 BackupPolicyMode 参数为 DataBackupPolicy 时生效。

Standard

BackupInterval

string

快照备份频率。取值:

  • 15:15 分钟。

  • 30:30 分钟。

  • 60:60 分钟。

  • 120:120 分钟。

  • 180:180 分钟。

  • 240:240 分钟。

  • 360:360 分钟。

  • 480:480 分钟。

  • 720:720 分钟。

说明
  • PreferredBackupPeriod 参数共同决定备份策略。

  • MySQL 实例必须是云盘 5.7、8.0 高可用系列、集群系列实例。

  • PostgreSQL 实例必须是云盘实例。

  • SQL Server 实例必须已开启快照备份

  • Category 参数为 Flash 时本参数无效。

  • 该参数仅在 BackupPolicyMode 参数为 DataBackupPolicy 时生效。

30

BackupMethod

string

SQL Server 云盘版实例的备份方式。取值:

  • Physical(默认值):物理备份

  • Snapshot:快照备份

说明

该参数仅在 BackupPolicyMode 参数为 DataBackupPolicy 时生效。

Physical

EnableIncrementDataBackup

boolean

SQL Server 云盘版、MySQL 本地盘实例是否开启增量备份。取值:

  • False(默认):关闭

  • True:开启

说明

该参数仅在 BackupPolicyMode 参数为 DataBackupPolicy 时生效。

False

IncBackupInterval

integer

MySQL 本地盘实例高频增量备份频率。取值:

  • 60:60 分钟。

  • 120:120 分钟。

  • 240:240 分钟。

  • 360:360 分钟。

  • 720:720 分钟。

说明

该参数仅在 EnableIncrementDataBackup 参数为 True 时生效。

120

BackupPriority

integer

SQL Server 集群版实例备库备份的设置选项。取值:

  • 1:优先备库

  • 2:强制主库

说明
  • 仅当 BackupMethod 取值为 Physical 时,该参数才生效。如果 BackupMethod 设置为 Snapshot,SQL Server 集群版实例将强制在主库备份。

  • 设置优先备库(BackupPriority 为 1)后,不支持开启 5 分钟日志备份策略(BackupLog 为 Enable 且 LogBackupFrequency 为空),否则将会报错。请将日志备份频率设置为每 30 分钟一次或与数据备份一致。

2

EnableAdvancedBackupPolicy

integer

AdvancedDataPolicies

array<object>

object

StrategyId

string

ActionType

string

OnlyPreserveOneEachHour

boolean

RetentionValue

integer

BakType

string

FilterKey

string

FilterValue

string

DestType

string

FilterType

string

SrcRegion

string

OnlyPreserveOneEachDay

boolean

SrcType

string

DestRegion

string

RetentionType

string

AdvancedLogPolicies

array<object>

object

StrategyId

string

ActionType

string

LogRetentionType

string

DestType

string

EnableLogBackup

integer

SrcType

string

SrcRegion

string

LogRetentionValue

integer

DestRegion

string

FilterKey

string

FilterValue

string

返回参数

名称

类型

描述

示例值

object

返回参数详情。

CompressType

string

备份压缩方式,取值:

  • 0:不压缩。

  • 1:zlib 压缩。

  • 2:并行 zlib 压缩。

  • 4:quicklz 压缩,开启了库表恢复。

  • 8:MySQL8.0 quicklz 压缩但是还未支持库表恢复。

4

DBInstanceID

string

实例 ID。

rm-uf6wjk5****

EnableBackupLog

string

是否开启日志备份。取值:

  • 1:开启

  • 0:关闭

说明

SQL Server 实例日志备份默认开启,无法关闭。

1

HighSpaceUsageProtection

string

MySQL 实例使用空间大于 80%,或者剩余空间小于 5 GB 时,是否无条件清理 Binlog。

Disable

LocalLogRetentionHours

integer

MySQL 实例日志备份本地保留小时数。

18

LocalLogRetentionSpace

string

MySQL 实例本地日志最大循环空间使用率。

30

LogBackupLocalRetentionNumber

integer

MySQL 实例本地 Binlog 保留个数。

60

RequestId

string

请求 ID。

DA147739-AEAD-4417-9089-65E9B1D8240D

EnableIncrementDataBackup

boolean

IncBackupInterval

integer

EnablePitrProtection

boolean

示例

正常返回示例

JSON格式

{
  "CompressType": "4",
  "DBInstanceID": "rm-uf6wjk5****",
  "EnableBackupLog": "1",
  "HighSpaceUsageProtection": "Disable",
  "LocalLogRetentionHours": 18,
  "LocalLogRetentionSpace": "30",
  "LogBackupLocalRetentionNumber": 60,
  "RequestId": "DA147739-AEAD-4417-9089-65E9B1D8240D",
  "EnableIncrementDataBackup": true,
  "IncBackupInterval": 0,
  "EnablePitrProtection": true
}

异常返回示例

JSON格式

{
    "RequestId": "7463B73D-35CC-4D19-A010-6B8D65D242EF",
    "HostId": "rds.aliyuncs.com",
    "Code": "UnsupportedOperation",
    "Message": "The specified action is not supported."
}

错误码

HTTP status code

错误码

错误信息

描述

400 InvalidColdRetention.Format Invalid cold retention format.
400 InvalidLogBackupFrequency.Malformed Invalid log backup frequency. 日志备份频率(LogBackupFrequency)无效,请检查参数是否正确。
400 InvalidBackupRetentionPeriod.Malformed The specified backup retention period is invalid. 备份周期不能为空。请设置备份周期,备份周期不能小于1天或大于30天。
400 BackupPropertyNotFound Backup policy not found 操作失败,无法找到备份策略。
400 OperationDenied.SwitchToSnapshot Snapshot backup does not support cross region storage at present. Please turn off cross region backup before switching to snapshot backup mode. 操作失败,快照备份目前不支持跨区域存储。在切换到快照备份模式之前,请关闭跨区域备份。
400 InvalidReleasedKeepPolicy.Format Specified Released Keep Policy is not valid. 实例释放后的归档备份保留策略无效。
400 IncorrectBackupPolicy The current instance has an advanced backup policy enabled. Currently, you cannot use the OpenAPI to modify the backup policy. You need to modify the backup policy in the console. 当前实例开启了高级备份策略,目前不支持使用OpenAPI修改备份策略,需要在控制台进行修改。
400 Order.ComboInstanceNotAllowOperate A package instance is not allowed to operate independently. 套餐实例不允许单独操作。
400 Price.PricingPlanResultNotFound Pricing plan price result not found. 定价计划价格结果没有找到。
400 Order.NoRealNameAuthentication You have not passed the real-name authentication and do not meet the purchase conditions. Please log in to the user center for real-name authentication. 您还未通过实名认证,不符合购买条件,请登录费用与成本进行实名认证。
400 InsufficientAvailableQuota Your account quota limit is less than 0, please recharge before trying to purchase. 您的账户可用额度小于0,请先充值后再尝试购买。
400 CommodityServiceCalling.Exception Failed to call commodity service. 调用商品服务返回失败。
400 RegionDissolvedEOM Dear customer, Alibaba Cloud plans to optimize and adjust the current region. Cloud services in this region will cease operations. You are currently unable to operate new purchase orders. Thank you for your understanding and support. 客户您好,阿里云计划对当前地域进行优化调整,该区域云服务将停止运营,为确保您的业务连续性及数据迁移工作的平稳过渡,您目前无法操作新购类型的订单,感谢理解与支持。
400 Commodity.InvalidComponent The module you purchased is not legal, please buy it again. 您购买的模块不合法,请重新购买。
400 RegionEndTimeDissolvedAustralia Cloud services in the Australia (Sydney) region will be discontinued. Set the validity date to September 30, 2024 or earlier than September 30, 2024. 客户您好,该地域已裁撤。
400 Price.CommoditySys Commodity system call exception. 商品系统调用异常。
400 Pay.InsufficientBalance Insufficient available balance. 可用金不足。
400 Order.PeriodInvalid There is a problem with the period you selected, please choose again. 您选购的周期有问题,请重新选购。
400 pay.noCreditCard Account not bound to credit card. 账户未绑定信用卡。
400 Order.InstHasUnpaidOrder There is an unpaid order for the service you have purchased. Please pay or void it before placing the order. 您选购的服务存在未支付订单,请支付或作废后再下单。
400 noAvailablePaymentMethod No payment method is specified for your account. We recommend that you add a payment method. 没有为您的账户指定付款方式。我们建议您添加一种付款方式。
400 BasicInfoUncompleted Your information is incomplete. Complete your information before the operation. 您的基本信息未完善,请在操作前先完善您的基本信息。
400 Risk.RiskControlRejection Your account is abnormal, please contact customer service for details. 您的账户出现异常,详情请联系客服。
400 Api.NotSupport Specified api is not supported. 当前接口不支持。
400 ContainForbiddenLabelError There is a label that prohibits placing orders. Please contact your distributor for assistance. 存在禁止下单的标签,请联系您的分销商处理
400 InvalidDBInstanceId.NotFound The DBInstanceId provided does not exist in records. 提供的DBInstanceId不存在。
400 InvalidInstanceLevel.DiskType Specified instance level not support request disk type 当前实例规格不支持该存储类型。
400 InvalidParam Sepcified wal level Parameter is invalid. There are still logical slots in instance, so it can not be set as replica. 指定的 wal_level 参数无效。实例中仍然存在复制槽,因此无法将其设置为replica。
400 KmsApiError User secret key invalid. 用户密钥失效。
400 System.SaleValidateFailed Sales expression validation system error. 销售表达式校验系统错误。
400 Abs.InvalidAccount.NotFound account is not found. 账户不存在。
400 SqlExecuteFailedOrTimeout sql command execution failed or timed out:%s. sql命令执行失败或执行超时
400 ColdData.EngineVersionNotSupport The current instance engine version not support coldDataEnabled. 当前实例引擎版本不支持归档冷数据。
400 ColdData.MinorVersionNotSupport The current instance minor version not support coldDataEnabled. 当前内核版本不支持归档冷数据。
400 IncorrectTargetClasscode The current instance type does not support this operation. 当前规格不支持此操作。
400 InvalidConnectionString.Duplicate Specified connection string already exists in the RDS. 链接地址名重复,请重新设置连接字符串。
400 RequiredParam.NotFound Required input param is not found. 没有传入必要的参数。
400 Parameters.Invalid Parameter error, please check the parameters. 参数错误,请检查参数。
400 BackupPolicyNotSupport Cold Data won't open with CrossBackup or Flash Backup, please check Backup Policy. 数据归档不支持跨地域备份和秒级快照,请检查备份策略。
400 InvalideStatus.Format The instance status does not support this operation. 实例状态不支持此操作。
400 InvalidDBInstanceEngineType.Format the DB instance engine type does not support this operation. DB实例引擎类型不支持此操作。
400 Pay.NoCreditCard No credit cards. 无信用卡。
400 VpcNetworkTypeNotSupport The vpc network type instance does not support this operation. vpc网络类型实例不支持此操作。
400 MirrorInsExists Specified DB instance mirror ins already existed. 当前数据库实例镜像已存在。
400 UnsupportedClassCode The specified DB instance class stops selling. 实例规格停止售卖。
400 InvalidBackupSet The specified database does not exist in the backup set. 备份集中没有指定的数据库。
400 OrdTCommodityQueryError Failed to query for product. 查询产品失败。
400 ProductInstanceReleased The instance has been released. Please check before placing the order. 实例已释放,请核实后下单。
400 RegionEndTimeDissolvedIndia The region is no longer supported. 指定的地域无效。
400 InvalidDiskType Current disk type does not support this operation. 当前的磁盘类型不支持该操作
400 InvalidIncrementBackupInterval.Malformed Parameter 'IncBackupInterval' is invalid. IncBackupInterval参数值非法。
400 InvalidLocalLogRetentionSpace.Malformed Parameter 'LocalLogRetentionSpace' is invalid. LocalLogRetentionSpace参数设置非法。
400 InvalidLocalLogRetentionHours.Malformed Parameter 'LocalLogRetentionHours' is invalid. LocalLogRetentionHours参数设置非法。
400 InvalidLogBackupLocalRetentionNumber.Malformed Parameter 'LogBackupLocalRetentionNumber' is invalid. LogBackupLocalRetentionNumber参数设置非法。
400 InvalidBackupInterval.Unsupported BackupInterval can be configured only when Category is set to Standard. The current instance is set to Flash. Please set Category to Standard. 当前实例已开启“秒级备份”(Category=Flash),仅当Category值为Standard时才支持配置 BackupInterval。请设置Category值为Standard,再设置BackupInterval参数。
400 InvalidPitrSetting Log backup is disabled. Enable PITR requires log backup to be enabled. 日志备份已关闭,开启“任意时间点恢复”需要日志备份开启。
500 ExternalFailure The request processing has failed due to external service failure. 请求服务失败,请稍后重试。
500 RequestMetaDataFailed The service request failed. Please try again later or contact service personnel. 请求服务失败,请稍后再试或联系服务人员。
500 InvokeProxyFailure The request processing has failed due to service failure of rds api. 由于rds api服务失败,请求处理失败。
403 IncorrectCategory Current Instance type does not support Category. 当前实例类型不支持类别。
403 OperationDenied.SwitchSnapshotToPhysical Only physical backup to snapshot backup is supported. 当前操作仅支持物理备份到快照备份。
403 OperationDenied.ModifyBackupSwitchOff The switch is not turned on. It is forbidden to modify the backup mode. 切换失败,未开启跨地域备份。
403 OperationDenied.ApiForbiddenForLogBackupFrequency When the instance is a snapshot backup, the log backup frequency is not allowed to be consistent with the data backup. 当实例为快照备份时,日志备份频率不允许为"与数据备份一致"。
403 OperationDenied.NotSupportedBackupMethod When the storage is larger than 4000 GB, only snapshot backup is supported. 当存储空间大于4000GB,仅支持快照备份。
403 OperationDenied.ApiForbidden Operation is not permitted. 操作不允许
403 OrderStatus.UnPaid The specified db instance has unpaid order. 实例当前存在未支付订单,请支付后重试。
403 InvalidReduceDiskSize The storage capacity after the scale-down must be larger than the used amount. 缩容目标容量不能小于当前存储空间使用量
403 CloudSSDNotSupport Cloud ssd does not support this operation, please upgrade to essd. SSD盘不支持此操作,请升级至ESSD。
403 InvalidUserOperatorPermission The user permission does not support this operation. 用户权限不支持此操作。
403 InvalidVswitchId Specified conn vswitch id is not valid. 指定的VSwitchId格式不正确或为空
403 IncorrectMinorVersion Current engine minor version does not support operations. 当前引擎小版本不支持此操作。
403 OperationDenied.ZoneResource There is no available zone for inventory. 没有可用的库存区域。
403 NotInFlowController Sorry,no permission. 非集团上云用户不可用,无权限。
403 InvalidKmsKey Kms key is disabled. Kms key已禁用。
403 InvalidInstanceLevel.Malformed Current DB instance level does not support this operation. 当前数据库实例级别不支持此操作。
403 IncorrectDBInstanceState Current DB instance state does not support this operation. 当前实例状态不支持此操作。
404 InvalidClusterKms The current instance does not authorized to access the Key Management Service. 当前实例未授权访问密钥管理服务。
404 Request.NotFound The requested resource is not available. 请求的资源不可用。
404 HostInfo.NotFound The specified host info is not found. 指定的主机信息不存在。
404 InvalidInsType.Malformed Specified instance type is not valid. 实例类型无效。
404 IncorrectDBInstanceLockMode Current DB instance lock mode does not support this operation. 操作失败,实例处于锁定状态。
408 NetworkOrSqlTimeoutError Failed to create login due to potential SQL Server overload or other issues that may cause the login creation fail. Please retry later. 由于潜在的SQL Server过载或实例账号过多,导致查询超时失败。

访问错误中心查看更多错误码。

变更历史

更多信息,参考变更详情