variable "nextcloud_backup" { type = string description = "HCL config for Restic Scheduler jobs" } variable "consul_backup" { type = string description = "HCL config for Restic Scheduler jobs" } job "backup" { datacenters = ["dc1"] type = "system" constraint { attribute = "${node.unique.name}" # Only node with a backup job so far # Remove when backing up all nodes value = "n2" } group "backup" { network { mode = "bridge" port "metrics" { to = 8080 } } volume "all-volumes" { type = "host" read_only = true source = "all-volumes" } service { port = "metrics" # Add connect to mysql connect { sidecar_service { proxy { local_service_port = 8080 upstreams { destination_name = "mysql-server" local_bind_port = 6060 } config { protocol = "tcp" } } } sidecar_task { resources { cpu = 50 memory = 50 } } } meta { metrics_addr = "${NOMAD_ADDR_metrics}" } } task "backup" { driver = "docker" volume_mount { volume = "all-volumes" destination = "/data" read_only = true } config { image = "iamthefij/resticscheduler" ports = ["metrics"] args = [ "/jobs/node-jobs.hcl", ] mount { type = "bind" target = "/jobs" source = "jobs" } } vault { policies = [ "access-tables", "nomad-task", ] } env = { "MYSQL_HOST" = "${NOMAD_UPSTREAM_IP_mysql_server}" "MYSQL_PORT" = "${NOMAD_UPSTREAM_PORT_mysql_server}" } template { # Probably want to use database credentials that have access to dump all tables data = <