Run mysql on the primary storage machine.

This commit is contained in:
2025-10-22 13:20:13 +01:00
parent 967ff34a51
commit 65835e1ed0
2 changed files with 15 additions and 7 deletions

View File

@@ -3,11 +3,17 @@ job "mysql-backup" {
type = "batch"
periodic {
cron = "23 23 * * * *"
crons = ["23 23 * * * *"]
prohibit_overlap = true
}
group "db" {
# Run on primary storage node for fast local disk access
constraint {
attribute = "${meta.storage_role}"
value = "primary"
}
task "backup" {
driver = "raw_exec"
@@ -21,7 +27,7 @@ job "mysql-backup" {
data = <<EOH
set -e
/run/current-system/sw/bin/nomad alloc exec -job -task=mysqld mysql \
mysqldump -u root --password="$MYSQL_ROOT_PASS" --all-databases > /data/compute/appdata/db-backups/mysql/backup.sql && \
mysqldump -u root --password="$MYSQL_ROOT_PASS" --all-databases > /data/services/db-backups/mysql/backup.sql && \
echo "last_success $(date +%s)" | \
/run/current-system/sw/bin/curl --data-binary @- http://pushgateway.service.consul:9091/metrics/job/mysql_backup
EOH