-
Notifications
You must be signed in to change notification settings - Fork 709
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create Backup Policy for SQLDatabase and SAPHanaDatabase (#1843)
* init code for backup policy vm workload * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * update code * separate SQLDatabase and SAPHana * init code example * revert code * refactor backup policy code * add example to workflow 106 * refactor backup_policies_vm_workloads implementation * enforce required for backup block * fix policy_type error * fix protection_policy error * add saphana tfvars --------- Co-authored-by: thanhlcao <[email protected]> Co-authored-by: khairi <[email protected]>
- Loading branch information
1 parent
8343019
commit df0a1ae
Showing
5 changed files
with
166 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
examples/recovery_vault/106-backupvault-with-sqldatabase-saphana/configuration.tfvars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
global_settings = { | ||
regions = { | ||
region1 = "australiaeast" | ||
} | ||
} | ||
resource_groups = { | ||
primary = { | ||
name = "backup_policy_sql" | ||
region = "region1" | ||
} | ||
} | ||
|
||
|
73 changes: 73 additions & 0 deletions
73
examples/recovery_vault/106-backupvault-with-sqldatabase-saphana/recovery_vaults.tfvars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
recovery_vaults = { | ||
asr1 = { | ||
name = "vault_re1" | ||
resource_group_key = "primary" | ||
region = "region1" | ||
vnet_key = "vnet_region1" | ||
subnet_key = "asr_subnet" | ||
|
||
soft_delete_enabled = false | ||
backup_policies = { | ||
vm_workloads = { | ||
sql = { | ||
name = "SQLTest" | ||
workload_type = "SQLDataBase" | ||
vault_key = "asr1" | ||
rg_key = "primary" | ||
timezone = "UTC" | ||
compression_enabled = false | ||
protection_policies = { | ||
sqlfull = { | ||
policy_type = "Full" | ||
backup = { | ||
frequency = "Daily" | ||
time = "15:00" | ||
} | ||
retention_daily = { | ||
count = 8 | ||
} | ||
} | ||
sqllog = { | ||
policy_type = "Log" | ||
backup = { | ||
frequency_in_minutes = 15 | ||
} | ||
simple_retention = { | ||
count = 8 | ||
} | ||
} | ||
} | ||
} | ||
saphana = { | ||
name = "SAPHANATest" | ||
workload_type = "SAPHanaDatabase" | ||
vault_key = "asr1" | ||
rg_key = "primary" | ||
timezone = "UTC" | ||
compression_enabled = false | ||
protection_policies = { | ||
saphanafull = { | ||
policy_type = "Full" | ||
backup = { | ||
frequency = "Daily" | ||
time = "15:00" | ||
} | ||
retention_daily = { | ||
count = 8 | ||
} | ||
} | ||
saphanalog = { | ||
policy_type = "Log" | ||
backup = { | ||
frequency_in_minutes = 15 | ||
} | ||
simple_retention = { | ||
count = 8 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
resource "azurerm_backup_policy_vm_workload" "vm_workload" { | ||
for_each = try(var.settings.backup_policies.vm_workloads, {}) | ||
|
||
name = each.value.name | ||
resource_group_name = local.resource_group_name | ||
recovery_vault_name = azurerm_recovery_services_vault.asr.name | ||
workload_type = each.value.workload_type | ||
|
||
settings { | ||
time_zone = each.value.timezone | ||
compression_enabled = each.value.compression_enabled | ||
} | ||
|
||
dynamic "protection_policy" { | ||
for_each = each.value.protection_policies | ||
|
||
content { | ||
policy_type = protection_policy.value.policy_type | ||
|
||
backup { | ||
frequency = try(protection_policy.value.backup.frequency, null) | ||
frequency_in_minutes = try(protection_policy.value.backup.frequency_in_minutes, null) | ||
time = try(protection_policy.value.backup.time, null) | ||
weekdays = try(protection_policy.value.backup.weekdays, null) | ||
} | ||
|
||
dynamic "retention_daily" { | ||
for_each = lookup(protection_policy.value, "retention_daily", null) == null ? [] : [1] | ||
|
||
content { | ||
count = protection_policy.value.retention_daily.count | ||
} | ||
} | ||
|
||
dynamic "retention_weekly" { | ||
for_each = lookup(protection_policy.value, "retention_weekly", null) == null ? [] : [1] | ||
|
||
content { | ||
count = protection_policy.value.retention_weekly.count | ||
weekdays = protection_policy.value.retention_weekly.weekdays | ||
} | ||
} | ||
|
||
dynamic "retention_monthly" { | ||
for_each = lookup(protection_policy.value, "retention_monthly", null) == null ? [] : [1] | ||
|
||
content { | ||
count = protection_policy.value.retention_monthly.count | ||
format_type = protection_policy.value.retention_monthly.format_type | ||
monthdays = try(protection_policy.value.retention_monthly.monthdays, null) | ||
weekdays = try(protection_policy.value.retention_monthly.weekdays, null) | ||
weeks = try(protection_policy.value.retention_monthly.weeks, null) | ||
} | ||
} | ||
|
||
dynamic "retention_yearly" { | ||
for_each = lookup(protection_policy.value, "retention_yearly", null) == null ? [] : [1] | ||
|
||
content { | ||
count = protection_policy.value.retention_yearly.count | ||
format_type = protection_policy.value.retention_yearly.format_type | ||
months = protection_policy.value.retention_yearly.months | ||
monthdays = try(protection_policy.value.retention_yearly.monthdays, null) | ||
weekdays = try(protection_policy.value.retention_yearly.weekdays, null) | ||
weeks = try(protection_policy.value.retention_yearly.weeks, null) | ||
} | ||
} | ||
|
||
dynamic "simple_retention" { | ||
for_each = lookup(protection_policy.value, "simple_retention", null) == null ? [] : [1] | ||
|
||
content { | ||
count = protection_policy.value.simple_retention.count | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters