Skip to content
Open
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
1 change: 1 addition & 0 deletions backupdr/backup_plan/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ resource "google_backup_dr_backup_plan" "default" {
backup_plan_id = "my-bp"
resource_type = "compute.googleapis.com/Instance"
backup_vault = google_backup_dr_backup_vault.default.name
# log_retention_days = 2 # Only applicable for Cloud SQL
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be created in a separate PR. It's unrelated to this feature

Copy link
Author

Choose a reason for hiding this comment

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

Actually both the changes were part of the same bug that is why created a single pull request.

Copy link
Author

Choose a reason for hiding this comment

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

I am sorry but we would need to hold this PR for a few days as there is some issue which is being resolved , thanks!


backup_rules {
rule_id = "rule-1"
Expand Down
58 changes: 58 additions & 0 deletions backupdr/backup_plan_association/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ resource "google_compute_disk" "default" {
zone = "us-central1-a"
}

resource "google_sql_database_instance" "default" {
name = "instance-test"
database_version = "MYSQL_8_0_41"
region = "us-central1"
settings {
tier = "db-f1-micro"
backup_configuration {
enabled = true
}
}
lifecycle {
ignore_changes = [
settings[0].backup_configuration[0].enabled,
]
}
deletion_protection = false
}

resource "google_backup_dr_backup_vault" "default" {
provider = google-beta
location = "us-central1"
Expand Down Expand Up @@ -129,6 +147,31 @@ resource "google_backup_dr_backup_plan" "disk_default" {
}
}

resource "google_backup_dr_backup_plan" "csql_default" {
provider = google-beta
location = "us-central1"
backup_plan_id = "my-csql-bp"
resource_type = "sqladmin.googleapis.com/Instance"
backup_vault = google_backup_dr_backup_vault.default.name
log_retention_days = 2

backup_rules {
rule_id = "rule-1"
backup_retention_days = 7

standard_schedule {
recurrence_type = "HOURLY"
hourly_frequency = 6
time_zone = "UTC"

backup_window {
start_hour_of_day = 0
end_hour_of_day = 23
}
}
}
}

# [START backupdr_create_backupplanassociation]

# Before creating a backup plan association, you need to create backup plan (google_backup_dr_backup_plan)
Expand Down Expand Up @@ -158,3 +201,18 @@ resource "google_backup_dr_backup_plan_association" "disk_association" {
}

# [END backupdr_create_backupplanassociation_disk]

# [START backupdr_create_backupplanassociation_csql]

# Before creating a backup plan association, you need to create backup plan (google_backup_dr_backup_plan)
# and Cloud SQL Instance (google_sql_database_instance).
resource "google_backup_dr_backup_plan_association" "csql_association" {
provider = google-beta
location = "us-central1"
backup_plan_association_id = "my-csql-bpa"
resource = "projects/${google_sql_database_instance.default.project}/instances/${google_sql_database_instance.default.name}"
resource_type = "sqladmin.googleapis.com/Instance"
backup_plan = google_backup_dr_backup_plan.csql_default.name
}

# [END backupdr_create_backupplanassociation_csql]
Loading