diff --git a/services/postgres-backup.hcl b/services/postgres-backup.hcl index d51810e..a3e2f36 100644 --- a/services/postgres-backup.hcl +++ b/services/postgres-backup.hcl @@ -3,11 +3,17 @@ job "postgres-backup" { type = "batch" periodic { - cron = "22 22 * * * *" + crons = ["22 22 * * * *"] prohibit_overlap = true } group "db" { + # Run on primary storage node (zippy) where postgres runs + constraint { + attribute = "${meta.storage_role}" + value = "primary" + } + task "backup" { driver = "raw_exec" @@ -21,7 +27,7 @@ job "postgres-backup" { data = < /data/compute/appdata/db-backups/postgresql/backup.sql && \ + pg_dumpall -U postgres > /data/services/db-backups/postgresql/backup.sql && \ echo "last_success $(date +%s)" | \ /run/current-system/sw/bin/curl --data-binary @- http://pushgateway.service.consul:9091/metrics/job/postgres_backup EOH diff --git a/services/postgres.hcl b/services/postgres.hcl index 1c3c56d..621cf1f 100644 --- a/services/postgres.hcl +++ b/services/postgres.hcl @@ -7,6 +7,12 @@ job "postgres" { group "db" { + # Run on primary storage node (zippy) for local disk performance + constraint { + attribute = "${meta.storage_role}" + value = "primary" + } + network { port "db" { static = 5432 @@ -23,7 +29,7 @@ job "postgres" { config { image = "postgis/postgis:15-3.4-alpine" ports = ["db"] - volumes = [ "/data/compute/appdata/postgres:/var/lib/postgresql/data" ] + volumes = [ "/data/services/postgres:/var/lib/postgresql/data" ] } env { @@ -72,7 +78,7 @@ job "postgres" { config { image = "dpage/pgadmin4:latest" ports = ["admin"] - volumes = [ "/data/compute/appdata/pgadmin:/var/lib/pgadmin" ] + volumes = [ "/data/services/pgadmin:/var/lib/pgadmin" ] } env { diff --git a/services/wordpress-backup.hcl b/services/wordpress-backup.hcl index 5ddcb25..ffd79a2 100644 --- a/services/wordpress-backup.hcl +++ b/services/wordpress-backup.hcl @@ -3,7 +3,7 @@ job "wordpress-backup" { type = "batch" periodic { - cron = "*/5 * * * * *" + crons = ["*/5 * * * * *"] prohibit_overlap = true }