Skip to content

Commit fd96453

Browse files
Add disks example code for backup-plan and backup-plan-association
1 parent 690a755 commit fd96453

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

backupdr/backup_plan/main.tf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,32 @@ resource "google_backup_dr_backup_plan" "default" {
6767
}
6868

6969
# [END backupdr_create_backupplan]
70+
71+
# [START backupdr_create_backupplan_disk]
72+
73+
# Before creating a backup plan, you need to create backup vault (google_backup_dr_backup_vault).
74+
resource "google_backup_dr_backup_plan" "disk_default" {
75+
provider = google-beta
76+
location = "us-central1"
77+
backup_plan_id = "my-disk-bp"
78+
resource_type = "compute.googleapis.com/Disk"
79+
backup_vault = google_backup_dr_backup_vault.default.name
80+
81+
backup_rules {
82+
rule_id = "rule-1"
83+
backup_retention_days = 5
84+
85+
standard_schedule {
86+
recurrence_type = "HOURLY"
87+
hourly_frequency = 1
88+
time_zone = "UTC"
89+
90+
backup_window {
91+
start_hour_of_day = 0
92+
end_hour_of_day = 6
93+
}
94+
}
95+
}
96+
}
97+
98+
# [END backupdr_create_backupplan_disk]

backupdr/backup_plan_association/main.tf

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ resource "google_compute_instance" "default" {
5353
}
5454
}
5555

56+
resource "google_compute_disk" "default" {
57+
name = "disk-data"
58+
type = "pd-standard"
59+
zone = "us-west1-a"
60+
size = "5"
61+
}
62+
5663
resource "google_backup_dr_backup_vault" "default" {
5764
provider = google-beta
5865
location = "us-central1"
@@ -99,6 +106,30 @@ resource "google_backup_dr_backup_plan" "default" {
99106
}
100107
}
101108

109+
resource "google_backup_dr_backup_plan" "disk_default" {
110+
provider = google-beta
111+
location = "us-central1"
112+
backup_plan_id = "my-disk-bp"
113+
resource_type = "compute.googleapis.com/Disk"
114+
backup_vault = google_backup_dr_backup_vault.default.name
115+
116+
backup_rules {
117+
rule_id = "rule-1"
118+
backup_retention_days = 5
119+
120+
standard_schedule {
121+
recurrence_type = "HOURLY"
122+
hourly_frequency = 1
123+
time_zone = "UTC"
124+
125+
backup_window {
126+
start_hour_of_day = 0
127+
end_hour_of_day = 6
128+
}
129+
}
130+
}
131+
}
132+
102133
# [START backupdr_create_backupplanassociation]
103134

104135
# Before creating a backup plan association, you need to create backup plan (google_backup_dr_backup_plan)
@@ -113,3 +144,18 @@ resource "google_backup_dr_backup_plan_association" "default" {
113144
}
114145

115146
# [END backupdr_create_backupplanassociation]
147+
148+
# [START backupdr_create_backupplanassociation_disk]
149+
150+
# Before creating a backup plan association, you need to create backup plan (google_backup_dr_backup_plan)
151+
# and compute disk (google_compute_disk or google_compute_region_disk).
152+
resource "google_backup_dr_backup_plan_association" "default" {
153+
provider = google-beta
154+
location = "us-central1"
155+
backup_plan_association_id = "my-disk-bpa"
156+
resource = google_compute_disk.default.id
157+
resource_type = "compute.googleapis.com/Disk"
158+
backup_plan = google_backup_dr_backup_plan.disk_default.name
159+
}
160+
161+
# [END backupdr_create_backupplanassociation_disk]

0 commit comments

Comments
 (0)