ops: add verified PostgreSQL backups
CI / test (push) Successful in 10s

This commit is contained in:
m
2026-08-16 17:53:40 +03:00
parent 6303dfe6eb
commit e9594306e5
8 changed files with 271 additions and 2 deletions
+30
View File
@@ -0,0 +1,30 @@
#!/bin/sh
set -eu
schedule_file="${1:-/home/m/assistant-ops/assistant-postgres-backup.crontab}"
marker="/home/m/assistant-ops/backup-postgres.sh"
current="$(mktemp)"
updated="$(mktemp)"
cleanup() {
rm -f -- "$current" "$updated"
}
trap cleanup EXIT HUP INT TERM
if [ ! -f "$schedule_file" ]; then
echo "Cron schedule file not found: $schedule_file" >&2
exit 1
fi
crontab -l >"$current" 2>/dev/null || true
grep -vF "$marker" "$current" >"$updated" || true
cat "$schedule_file" >>"$updated"
crontab "$updated"
matches="$(crontab -l | grep -Fc "$marker")"
if [ "$matches" -ne 1 ]; then
echo "Expected one backup cron entry, found $matches" >&2
exit 1
fi
echo "PostgreSQL backup cron entry installed"