Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
29 changes: 29 additions & 0 deletions backupdr/backup_plan/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,32 @@ resource "google_backup_dr_backup_plan" "default" {
}

# [END backupdr_create_backupplan]

# [START backupdr_create_backupplan_disk]

# Before creating a backup plan, you need to create backup vault (google_backup_dr_backup_vault).
resource "google_backup_dr_backup_plan" "disk_default" {
provider = google-beta
location = "us-central1"
backup_plan_id = "my-disk-bp"
resource_type = "compute.googleapis.com/Disk"
backup_vault = google_backup_dr_backup_vault.default.name

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

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

backup_window {
start_hour_of_day = 0
end_hour_of_day = 6
}
}
}
}

# [END backupdr_create_backupplan_disk]
45 changes: 45 additions & 0 deletions backupdr/backup_plan_association/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ resource "google_compute_instance" "default" {
}
}

resource "google_compute_disk" "default" {
name = "disk-data"
type = "pd-standard"
zone = "us-central1-a"
}

resource "google_backup_dr_backup_vault" "default" {
provider = google-beta
location = "us-central1"
Expand Down Expand Up @@ -99,6 +105,30 @@ resource "google_backup_dr_backup_plan" "default" {
}
}

resource "google_backup_dr_backup_plan" "disk_default" {
provider = google-beta
location = "us-central1"
backup_plan_id = "my-disk-bp"
resource_type = "compute.googleapis.com/Disk"
backup_vault = google_backup_dr_backup_vault.default.name

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

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

backup_window {
start_hour_of_day = 0
end_hour_of_day = 6
}
}
}
}

# [START backupdr_create_backupplanassociation]

# Before creating a backup plan association, you need to create backup plan (google_backup_dr_backup_plan)
Expand All @@ -113,3 +143,18 @@ resource "google_backup_dr_backup_plan_association" "default" {
}

# [END backupdr_create_backupplanassociation]

# [START backupdr_create_backupplanassociation_disk]

# Before creating a backup plan association, you need to create backup plan (google_backup_dr_backup_plan)
# and compute disk (google_compute_disk or google_compute_region_disk).
resource "google_backup_dr_backup_plan_association" "default" {
provider = google-beta
location = "us-central1"
backup_plan_association_id = "my-disk-bpa"
resource = google_compute_disk.default.id
resource_type = "compute.googleapis.com/Disk"
backup_plan = google_backup_dr_backup_plan.disk_default.name
}

# [END backupdr_create_backupplanassociation_disk]