Provides an RDS instance backup policy resource and used to configure instance backup policy, see What is DB Backup Policy.
variable "name" {
default = "tf-example"
}
data "alicloud_db_zones" "default" {
engine = "MySQL"
engine_version = "5.6"
}
resource "alicloud_vpc" "default" {
vpc_name = var.name
cidr_block = "172.16.0.0/16"
}
resource "alicloud_vswitch" "default" {
vpc_id = alicloud_vpc.default.id
cidr_block = "172.16.0.0/24"
zone_id = data.alicloud_db_zones.default.zones.0.id
vswitch_name = var.name
}
resource "alicloud_db_instance" "instance" {
engine = "MySQL"
engine_version = "5.6"
instance_type = "rds.mysql.s1.small"
instance_storage = "10"
vswitch_id = alicloud_vswitch.default.id
instance_name = var.name
}
resource "alicloud_db_backup_policy" "policy" {
instance_id = alicloud_db_instance.instance.id
}
The following arguments are supported:
instance_id
- (Required, ForceNew) The Id of instance that can run database.backup_period
- (Deprecated) It has been deprecated from version 1.69.0, and use field 'preferred_backup_period' instead.preferred_backup_period
- (Optional, Available since v1.69.0) DB Instance backup period. Please set at least two days to ensure backing up at least twice a week. Valid values: [Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday].backup_time
- (Deprecated) It has been deprecated from version 1.69.0, and use field 'preferred_backup_time' instead.preferred_backup_time
- (Optional, Available since v1.69.0) DB instance backup time, in the format of HH:mmZ- HH:mmZ. Time setting interval is one hour. Default to "02:00Z-03:00Z". China time is 8 hours behind it.retention_period
- (Deprecated) It has been deprecated from version 1.69.0, and use field 'backup_retention_period' instead.backup_retention_period
- (Optional, Available since v1.69.0) Instance backup retention days. Valid values: [7-730]. Default to 7. But mysql local disk is unlimited.log_backup
- (Deprecated) It has been deprecated from version 1.68.0, and use field 'enable_backup_log' instead.enable_backup_log
- (Optional, Available since v1.68.0) Whether to backup instance log. Valid values are true
, false
, Default to true
. Note: The 'Basic Edition' category Rds instance does not support setting log backup. What is Basic Edition.log_retention_period
- (Deprecated) It has been deprecated from version 1.69.0, and use field 'log_backup_retention_period' instead.log_backup_retention_period
- (Optional, Available since v1.69.0) Instance log backup retention days. Valid when the enable_backup_log
is 1
. Valid values: [7-730]. Default to 7. It cannot be larger than backup_retention_period
.local_log_retention_hours
- (Optional, Available since v1.69.0) Instance log backup local retention hours. Valid when the enable_backup_log
is true
. Valid values: [0-7*24].local_log_retention_space
- (Optional, Available since v1.69.0) Instance log backup local retention space. Valid when the enable_backup_log
is true
. Valid values: [0-50].high_space_usage_protection
- (Optional, Available since v1.69.0) Instance high space usage protection policy. Valid when the enable_backup_log
is true
. Valid values are Enable
, Disable
.log_backup_frequency
- (Optional, Available since v1.69.0) Instance log backup frequency. Valid when the instance engine is SQLServer
. Valid values are LogInterval
.compress_type
- (Optional, Available since v1.69.0) The compress type of instance policy. Valid values are 1
, 4
, 8
.archive_backup_retention_period
- (Optional, Available since v1.69.0) Instance archive backup retention days. Valid when the enable_backup_log
is true
and instance is mysql local disk. Valid values: [30-1095], and archive_backup_retention_period
must larger than backup_retention_period
730.archive_backup_keep_count
- (Optional, Available since v1.69.0) Instance archive backup keep count. Valid when the enable_backup_log
is true
and instance is mysql local disk. When archive_backup_keep_policy
is ByMonth
Valid values: [1-31]. When archive_backup_keep_policy
is ByWeek
Valid values: [1-7].archive_backup_keep_policy
- (Optional, Available since v1.69.0) Instance archive backup keep policy. Valid when the enable_backup_log
is true
and instance is mysql local disk. Valid values are ByMonth
, ByWeek
, KeepAll
.released_keep_policy
- (Optional, Available since v1.147.0) The policy based on which ApsaraDB RDS retains archived backup files if the instance is released. Default value: None. Valid values:
category
- (Optional, Available since v1.190.0) Whether to enable second level backup.Valid values are Flash
, Standard
, Note:It only takes effect when the BackupPolicyMode parameter is DataBackupPolicy.
The following attributes are exported:
id
- The current backup policy resource ID. It is same as 'instance_id'.RDS backup policy can be imported using the id or instance id, e.g.
$ terraform import alicloud_db_backup_policy.example "rm-12345678"