diff --git a/.changelog/2993.txt b/.changelog/2993.txt new file mode 100644 index 0000000000..d7f3a6cae4 --- /dev/null +++ b/.changelog/2993.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/tencentcloud_mysql_backup_policy: `backup_model` support `snapshot` +``` \ No newline at end of file diff --git a/tencentcloud/services/cdb/extension_mysql.go b/tencentcloud/services/cdb/extension_mysql.go index 4ddbea9a72..b01cdcede8 100644 --- a/tencentcloud/services/cdb/extension_mysql.go +++ b/tencentcloud/services/cdb/extension_mysql.go @@ -6,7 +6,7 @@ const ( var MYSQL_ALLOW_BACKUP_TIME = []string{"02:00-06:00", "06:00-10:00", "10:00-14:00", "14:00-18:00", "18:00-22:00", "22:00-02:00"} -var MYSQL_ALLOW_BACKUP_MODEL = []string{"logical", "physical"} +var MYSQL_ALLOW_BACKUP_MODEL = []string{"physical", "snapshot"} // mysql Status https://cloud.tencent.com/document/api/236/15872 const ( diff --git a/tencentcloud/services/cdb/resource_tc_mysql_backup_policy.go b/tencentcloud/services/cdb/resource_tc_mysql_backup_policy.go index 92ef5a3c86..39f37a9fba 100644 --- a/tencentcloud/services/cdb/resource_tc_mysql_backup_policy.go +++ b/tencentcloud/services/cdb/resource_tc_mysql_backup_policy.go @@ -35,9 +35,9 @@ func ResourceTencentCloudMysqlBackupPolicy() *schema.Resource { "backup_model": { Type: schema.TypeString, Optional: true, - Default: MYSQL_ALLOW_BACKUP_MODEL[1], + Default: MYSQL_ALLOW_BACKUP_MODEL[0], ValidateFunc: tccommon.ValidateAllowedStringValue(MYSQL_ALLOW_BACKUP_MODEL), - Description: "Backup method. Supported values include: `physical` - physical backup.", + Description: "Backup method. Supported values include: `physical` - physical backup; `snapshot` - snapshot backup. Multi node only support `physical`, Single node only support `snapshot`.", }, "backup_time": { Type: schema.TypeString, @@ -137,13 +137,10 @@ func resourceTencentCloudMysqlBackupPolicyUpdate(d *schema.ResourceData, meta in mysqlService := MysqlService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()} var ( - isUpdate = false - - mysqlId = d.Get("mysql_id").(string) - retentionPeriod = int64(d.Get("retention_period").(int)) - backupModel = d.Get("backup_model").(string) - backupTime = d.Get("backup_time").(string) - + mysqlId = d.Get("mysql_id").(string) + retentionPeriod = int64(d.Get("retention_period").(int)) + backupModel = d.Get("backup_model").(string) + backupTime = d.Get("backup_time").(string) binlogExpireDays int64 enableBinlogStandby string binlogStandbyDays int64 @@ -163,18 +160,12 @@ func resourceTencentCloudMysqlBackupPolicyUpdate(d *schema.ResourceData, meta in if d.HasChange("retention_period") || d.HasChange("backup_model") || d.HasChange("backup_time") || d.HasChange("binlog_period") || d.HasChange("enable_binlog_standby") || d.HasChange("binlog_standby_days") { - if backupModel != "physical" { - return fmt.Errorf("`backup_model` only support 'physical'") - } - isUpdate = true - } - - if isUpdate { err := mysqlService.ModifyBackupConfigByMysqlId(ctx, mysqlId, retentionPeriod, backupModel, backupTime, binlogExpireDays, enableBinlogStandby, binlogStandbyDays) if err != nil { return err } } + return resourceTencentCloudMysqlBackupPolicyRead(d, meta) } diff --git a/website/docs/r/mysql_backup_policy.html.markdown b/website/docs/r/mysql_backup_policy.html.markdown index 3d7a3888d3..97ab120452 100644 --- a/website/docs/r/mysql_backup_policy.html.markdown +++ b/website/docs/r/mysql_backup_policy.html.markdown @@ -80,7 +80,7 @@ resource "tencentcloud_mysql_backup_policy" "example" { The following arguments are supported: * `mysql_id` - (Required, String, ForceNew) Instance ID to which policies will be applied. -* `backup_model` - (Optional, String) Backup method. Supported values include: `physical` - physical backup. +* `backup_model` - (Optional, String) Backup method. Supported values include: `physical` - physical backup; `snapshot` - snapshot backup. Multi node only support `physical`, Single node only support `snapshot`. * `backup_time` - (Optional, String) Instance backup time, in the format of 'HH:mm-HH:mm'. Time setting interval is four hours. Default to `02:00-06:00`. The following value can be supported: `02:00-06:00`, `06:00-10:00`, `10:00-14:00`, `14:00-18:00`, `18:00-22:00`, and `22:00-02:00`. * `binlog_period` - (Optional, Int) Binlog retention time, in days. The minimum value is 7 days and the maximum value is 1830 days. This value cannot be set greater than the backup file retention time. * `binlog_standby_days` - (Optional, Int) The standard starting number of days for log backup storage. The log backup will be converted when it reaches the standard starting number of days for storage. The minimum is 30 days and must not be greater than the number of days for log backup retention.