From e9070db4cafb1f265688aeccb9fd9004852bed45 Mon Sep 17 00:00:00 2001 From: SevenEarth <391613297@qq.com> Date: Wed, 3 Dec 2025 16:35:24 +0800 Subject: [PATCH 1/2] add --- ...esource_tc_mongodb_instance_backup_rule.go | 92 ++++++++++++++++++- ...esource_tc_mongodb_instance_backup_rule.md | 1 + ...mongodb_instance_backup_rule.html.markdown | 14 ++- 3 files changed, 105 insertions(+), 2 deletions(-) diff --git a/tencentcloud/services/mongodb/resource_tc_mongodb_instance_backup_rule.go b/tencentcloud/services/mongodb/resource_tc_mongodb_instance_backup_rule.go index 4294b010ca..3177af1a33 100644 --- a/tencentcloud/services/mongodb/resource_tc_mongodb_instance_backup_rule.go +++ b/tencentcloud/services/mongodb/resource_tc_mongodb_instance_backup_rule.go @@ -26,7 +26,7 @@ func ResourceTencentCloudMongodbInstanceBackupRule() *schema.Resource { Required: true, ForceNew: true, Type: schema.TypeString, - Description: "Instance id.", + Description: "Instance ID.", }, "backup_method": { @@ -44,12 +44,66 @@ func ResourceTencentCloudMongodbInstanceBackupRule() *schema.Resource { Description: "Set the start time for automatic backup. The value range is: [0,23]. For example, setting this parameter to 2 means that backup starts at 02:00.", }, + "backup_frequency": { + Type: schema.TypeInt, + Optional: true, + Description: "Automatic backup frequency, for internal display, default value is 24h.", + }, + + "notify": { + Type: schema.TypeBool, + Optional: true, + Description: "Set whether to send failure alerts when automatic backup errors occur.\n- true: Send.\n- false: Do not send.", + }, + "backup_retention_period": { Optional: true, Computed: true, Type: schema.TypeInt, Description: "Specify the number of days to save backup data. The default is 7 days, and the support settings are 7, 30, 90, 180, 365.", }, + + "active_weekdays": { + Type: schema.TypeString, + Optional: true, + Description: "Which days of the week to backup, 0-6, comma separated. Only effective for advanced backup.", + }, + + "long_term_unit": { + Type: schema.TypeString, + Optional: true, + Description: "Long-term retention cycle, weekly, monthly, empty means not enabled.", + }, + + "long_term_active_days": { + Type: schema.TypeString, + Optional: true, + Description: "Which days to retain long-term, week 0-6, month 1-31, comma separated.", + }, + + "long_term_expired_days": { + Type: schema.TypeInt, + Optional: true, + Description: "How many days to retain long-term backups.", + }, + + "oplog_expired_days": { + Type: schema.TypeInt, + Optional: true, + Description: "How many days to retain incremental backups.", + }, + + "backup_version": { + Type: schema.TypeInt, + Optional: true, + Description: "Backup version. Old version backup is 0, advanced backup is 1. Set this value to 1 when enabling advanced backup.", + }, + + "alarm_water_level": { + Type: schema.TypeInt, + Optional: true, + Description: "Alert threshold. Range: 50-300.", + }, }, } } @@ -139,10 +193,46 @@ func resourceTencentCloudMongodbInstanceBackupRuleUpdate(d *schema.ResourceData, request.BackupTime = helper.IntUint64(v.(int)) } + if v, ok := d.GetOkExists("backup_frequency"); ok { + request.BackupFrequency = helper.IntUint64(v.(int)) + } + + if v, ok := d.GetOkExists("notify"); ok { + request.Notify = helper.Bool(v.(bool)) + } + if v, ok := d.GetOkExists("backup_retention_period"); ok { request.BackupRetentionPeriod = helper.IntUint64(v.(int)) } + if v, ok := d.GetOk("active_weekdays"); ok { + request.ActiveWeekdays = helper.String(v.(string)) + } + + if v, ok := d.GetOk("long_term_unit"); ok { + request.LongTermUnit = helper.String(v.(string)) + } + + if v, ok := d.GetOk("long_term_active_days"); ok { + request.LongTermActiveDays = helper.String(v.(string)) + } + + if v, ok := d.GetOkExists("long_term_expired_days"); ok { + request.LongTermExpiredDays = helper.IntInt64(v.(int)) + } + + if v, ok := d.GetOkExists("oplog_expired_days"); ok { + request.OplogExpiredDays = helper.IntInt64(v.(int)) + } + + if v, ok := d.GetOkExists("backup_version"); ok { + request.BackupVersion = helper.IntInt64(v.(int)) + } + + if v, ok := d.GetOkExists("alarm_water_level"); ok { + request.AlarmWaterLevel = helper.IntInt64(v.(int)) + } + request.InstanceId = &instanceId err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseMongodbClient().SetBackupRules(request) diff --git a/tencentcloud/services/mongodb/resource_tc_mongodb_instance_backup_rule.md b/tencentcloud/services/mongodb/resource_tc_mongodb_instance_backup_rule.md index 6fe946e7e9..6d3e243dcf 100644 --- a/tencentcloud/services/mongodb/resource_tc_mongodb_instance_backup_rule.md +++ b/tencentcloud/services/mongodb/resource_tc_mongodb_instance_backup_rule.md @@ -8,6 +8,7 @@ resource "tencentcloud_mongodb_instance_backup_rule" "example" { backup_method = 0 backup_time = 10 backup_retention_period = 7 + backup_version = 1 } ``` diff --git a/website/docs/r/mongodb_instance_backup_rule.html.markdown b/website/docs/r/mongodb_instance_backup_rule.html.markdown index 97069c6cb4..6904336e9a 100644 --- a/website/docs/r/mongodb_instance_backup_rule.html.markdown +++ b/website/docs/r/mongodb_instance_backup_rule.html.markdown @@ -19,6 +19,7 @@ resource "tencentcloud_mongodb_instance_backup_rule" "example" { backup_method = 0 backup_time = 10 backup_retention_period = 7 + backup_version = 1 } ``` @@ -31,8 +32,19 @@ The following arguments are supported: - 1: Physical backup; - 3: Snapshot backup (supported only in cloud disk version). * `backup_time` - (Required, Int) Set the start time for automatic backup. The value range is: [0,23]. For example, setting this parameter to 2 means that backup starts at 02:00. -* `instance_id` - (Required, String, ForceNew) Instance id. +* `instance_id` - (Required, String, ForceNew) Instance ID. +* `active_weekdays` - (Optional, String) Which days of the week to backup, 0-6, comma separated. Only effective for advanced backup. +* `alarm_water_level` - (Optional, Int) Alert threshold. Range: 50-300. +* `backup_frequency` - (Optional, Int) Automatic backup frequency, for internal display, default value is 24h. * `backup_retention_period` - (Optional, Int) Specify the number of days to save backup data. The default is 7 days, and the support settings are 7, 30, 90, 180, 365. +* `backup_version` - (Optional, Int) Backup version. Old version backup is 0, advanced backup is 1. Set this value to 1 when enabling advanced backup. +* `long_term_active_days` - (Optional, String) Which days to retain long-term, week 0-6, month 1-31, comma separated. +* `long_term_expired_days` - (Optional, Int) How many days to retain long-term backups. +* `long_term_unit` - (Optional, String) Long-term retention cycle, weekly, monthly, empty means not enabled. +* `notify` - (Optional, Bool) Set whether to send failure alerts when automatic backup errors occur. +- true: Send. +- false: Do not send. +* `oplog_expired_days` - (Optional, Int) How many days to retain incremental backups. ## Attributes Reference From d5027193162d4ce17fcfd275149029566ebee6cd Mon Sep 17 00:00:00 2001 From: SevenEarth <391613297@qq.com> Date: Wed, 3 Dec 2025 16:46:31 +0800 Subject: [PATCH 2/2] add --- .changelog/3627.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/3627.txt diff --git a/.changelog/3627.txt b/.changelog/3627.txt new file mode 100644 index 0000000000..44478b8abb --- /dev/null +++ b/.changelog/3627.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/tencentcloud_mongodb_instance_backup_rule: add new params +``` \ No newline at end of file