Files
miem_workers/infra/install-postgres-backup-cron.sh
agent 69c1dd52cf
All checks were successful
CI / test (pull_request) Successful in 9m12s
CI / deploy (pull_request) Has been skipped
fix: report scheduled backup failures
2026-09-15 18:53:06 +03:00

11 lines
424 B
Bash

#!/bin/sh
set -eu
temporary=$(mktemp)
app_dir=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
trap 'rm -f -- "$temporary"' EXIT HUP INT TERM
crontab -l 2>/dev/null | grep -v 'postgres-backup.sh' > "$temporary" || true
printf '%s\n' "30 3 * * 0 flock -w 3600 /tmp/miem-postgres-backup.lock $app_dir/infra/postgres-backup.sh || logger -t miem-postgres-backup -- 'backup skipped or failed'" >> "$temporary"
crontab "$temporary"