From 1df1f4595a489ed818e2cb85b0dad0685bcd0320 Mon Sep 17 00:00:00 2001 From: Jason Rothstein Date: Sun, 27 Apr 2025 20:05:53 -0500 Subject: [PATCH] Add backup policy to be set as daily or weekly Signed-off-by: Jason Rothstein --- resource.digitalocean_droplet.this.tf | 5 +++++ variable.backup_policy_hour.tf | 5 +++++ variable.backup_policy_plan.tf | 5 +++++ variable.backup_policy_weekday.tf | 5 +++++ 4 files changed, 20 insertions(+) create mode 100644 variable.backup_policy_hour.tf create mode 100644 variable.backup_policy_plan.tf create mode 100644 variable.backup_policy_weekday.tf diff --git a/resource.digitalocean_droplet.this.tf b/resource.digitalocean_droplet.this.tf index 905533e..b9d0f63 100644 --- a/resource.digitalocean_droplet.this.tf +++ b/resource.digitalocean_droplet.this.tf @@ -1,5 +1,10 @@ resource "digitalocean_droplet" "this" { backups = "true" + backup_policy { + plan = var.backup_policy_plan + weekday = var.backup_policy_weekday + hour = var.backup_policy_hour + } image = var.image_name ipv6 = "true" lifecycle { diff --git a/variable.backup_policy_hour.tf b/variable.backup_policy_hour.tf new file mode 100644 index 0000000..bd04c19 --- /dev/null +++ b/variable.backup_policy_hour.tf @@ -0,0 +1,5 @@ +variable "backup_policy_hour" { + # UTC Hour : 0, 4, 8, 12, 16, 20 + default = "0" + type = string +} diff --git a/variable.backup_policy_plan.tf b/variable.backup_policy_plan.tf new file mode 100644 index 0000000..0605a3b --- /dev/null +++ b/variable.backup_policy_plan.tf @@ -0,0 +1,5 @@ +variable "backup_policy_plan" { + # daily or weekly + default = "weekly" + type = string +} diff --git a/variable.backup_policy_weekday.tf b/variable.backup_policy_weekday.tf new file mode 100644 index 0000000..377422a --- /dev/null +++ b/variable.backup_policy_weekday.tf @@ -0,0 +1,5 @@ +variable "backup_policy_weekday" { + # SUN, MON, TUE, WED, THU, FRI, SAT + default = "SUN" + type = string +}