Description
Without explicit management of a CDB backup policy, retention and backup windows may not meet recovery needs. Omitting a separate Terraform policy resource does not itself disable the service’s automatic backups.
Potential impact
Required recovery points may expire, making it difficult to restore data lost through failure or mistakes.
Remediation
Associate tencentcloud_mysql_backup_policy with the instance and set retention_period, backup_time, and binlog_period for the required recovery window. Verify actual backups and restoration.
Examples
These excerpts manage the backup policy as code, retaining both data and binlogs for 32 days. Other instance settings, including networking, are omitted.
Before
hcl
resource "tencentcloud_mysql_instance" "db" {
engine_version = "5.7"
charge_type = "POSTPAID"
instance_name = "tf-example-mysql"
mem_size = 4000
volume_size = 200
intranet_port = 3306
}
After
hcl
resource "tencentcloud_mysql_instance" "db" {
engine_version = "5.7"
charge_type = "POSTPAID"
instance_name = "tf-example-mysql"
mem_size = 4000
volume_size = 200
intranet_port = 3306
}
resource "tencentcloud_mysql_backup_policy" "example" {
mysql_id = tencentcloud_mysql_instance.db.id
retention_period = 32
backup_model = "physical"
backup_time = "22:00-02:00"
binlog_period = 32
enable_binlog_standby = "off"
binlog_standby_days = 31
}