CDB backup policy is not explicitly managed

Manage database backup schedules to meet recovery needs.

Description

Check the backup policy applied to the TencentDB for MySQL instance. The service can take automatic backups even when Terraform declares no separate policy resource.

Potential impact

If a required data backup or binary log expires too early, the instance may have no usable recovery point from before a failure or mistaken change.

Remediation

Attach tencentcloud_mysql_backup_policy to the instance with mysql_id. Set backup_time for the backup window and align retention_period and binlog_period with the recovery period you need. Verify completed backups and test a restore.

Examples

The example schedules physical backups in the 22:00-02:00 window and retains data backups and binary logs for 32 days. Networking and the remaining instance settings 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
}

References