job "backup%{ if batch_node != null }-oneoff-${batch_node}%{ endif }" { datacenters = ["dc1"] priority = 90 %{ if batch_node == null ~} type = "system" %{ else ~} type = "batch" parameterized { meta_required = ["job_name"] meta_optional = ["task", "snapshot"] } meta { task = "backup" snapshot = "latest" } %{ endif ~} %{ if batch_node != null ~} constraint { attribute = "$${node.unique.name}" value = "${batch_node}" } %{ endif ~} group "backup" { network { mode = "bridge" port "metrics" { %{~ if use_wesher ~} host_network = "wesher" %{~ endif ~} to = 8080 } } volume "all-volumes" { type = "host" read_only = false source = "all-volumes" } ephemeral_disk { # Try to keep restic cache intact sticky = true } service { name = "backup" provider = "nomad" port = "metrics" tags = [ "prometheus.scrape" ] } task "backup" { driver = "docker" volume_mount { volume = "all-volumes" destination = "/data" read_only = false } config { image = "iamthefij/resticscheduler:0.4.0" ports = ["metrics"] args = [ %{ if batch_node != null ~} "-once", "-$${NOMAD_META_task}", "$${NOMAD_META_job_name}", "--snapshot", "$${NOMAD_META_snapshot}", "--push-gateway", "http://pushgateway.nomad:9091", %{ endif ~} "$${NOMAD_TASK_DIR}/node-jobs.hcl", ] } action "unlock" { command = "/bin/resticscheduler" args = ["-once", "-unlock", "all", "$${NOMAD_TASK_DIR}/node-jobs.hcl"] } env = { RCLONE_CHECKERS = "2" RCLONE_TRANSFERS = "2" RCLONE_FTP_CONCURRENCY = "5" RESTIC_CACHE_DIR = "$${NOMAD_ALLOC_DIR}/data" TZ = "America/Los_Angeles" } template { data = <