Skip to content

fix(cdb): [121024787] tencentcloud_mysql_backup_policy update backup_model #2993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/2993.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_mysql_backup_policy: `backup_model` support `snapshot`
```
2 changes: 1 addition & 1 deletion tencentcloud/services/cdb/extension_mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个logical直接没了?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

和产研侧沟通确认了下 并不存在该值,仅是一个示例假值


// mysql Status https://cloud.tencent.com/document/api/236/15872
const (
Expand Down
23 changes: 7 additions & 16 deletions tencentcloud/services/cdb/resource_tc_mysql_backup_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/mysql_backup_policy.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading