From d022fe9bc4d2ed4da74bcc9bb2bea695b15c3a93 Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Thu, 23 Jun 2022 09:49:57 -0700 Subject: [PATCH] Deploy backup jobs to all hosts and dynamically determine jobs per node --- backups/backup.nomad | 56 +++++++++++++++++--------------------------- setup-cluster.yml | 6 +++++ 2 files changed, 28 insertions(+), 34 deletions(-) diff --git a/backups/backup.nomad b/backups/backup.nomad index ba9eaf0..b23d3f9 100644 --- a/backups/backup.nomad +++ b/backups/backup.nomad @@ -5,10 +5,15 @@ variable "nextcloud_backup" { job "backup" { datacenters = ["dc1"] - type = "service" + type = "system" - group "nomad0" { - count = 1 + constraint { + attribute = "${node.unique.name}" + # Only node with a backup job so far + value = "n2" + } + + group "backup" { network { mode = "bridge" @@ -18,22 +23,10 @@ job "backup" { } } - volume "nextcloud-data" { + volume "all-volumes" { type = "host" read_only = true - source = "nextcloud-data" - } - - volume "gitea-data" { - type = "host" - read_only = true - source = "gitea-data" - } - - volume "authentik-data" { - type = "host" - read_only = true - source = "authentik-data" + source = "all-volumes" } service { @@ -73,20 +66,8 @@ job "backup" { driver = "docker" volume_mount { - volume = "nextcloud-data" - destination = "/data/nextcloud" - read_only = true - } - - volume_mount { - volume = "gitea-data" - destination = "/data/gitea" - read_only = true - } - - volume_mount { - volume = "authentik-data" - destination = "/data/authentik" + volume = "all-volumes" + destination = "/data" read_only = true } @@ -94,7 +75,7 @@ job "backup" { image = "iamthefij/resticscheduler" ports = ["metrics"] args = [ - "/jobs/nextcloud.hcl", + "/jobs/node-jobs.hcl", ] mount { @@ -117,8 +98,15 @@ job "backup" { } template { - data = var.nextcloud_backup - destination = "jobs/nextcloud.hcl" + data = <