fix(backup): make backup_scheduler actually run; add freshness alerting

busybox crond reads <dir>/<user>, but the crontab was mounted at
/etc/crontab, so no cron job had ever run: SQL dumps were last taken
2026-06-17 and the ntfy failure alerts never fired. Kopia's own server
schedule kept file snapshots going until its cache broke on 2026-08-28,
and nothing noticed for seven weeks.

- mount crontab at /etc/crontabs/root and run crond -c /etc/crontabs
- add hourly backup-check-freshness.sh: every Kopia source and the
  newest SQL dump must be <26h old and dumps must not be empty stubs;
  pushes UP/DOWN to the Uptime Kuma push monitor "Backups fresh" (#73),
  which also alerts via ntfy if no push arrives for 2h
- scheduler joins edge to reach uptime_kuma; jq added; KOPIA password
  and KUMA_PUSH_URL exported to /etc/backup.env for cron's bare env
- drop backup-run-snapshots.sh from cron (would duplicate the kopia
  server's 03:00 policy snapshots); keep it for manual runs
- bookstack dump used an unset MYSQL_PASSWORD (empty 20-byte gzip);
  dump_mariadb now takes the password env var name
- add immich-postgres and nextcloud-postgres dumps

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ginnoirandClaude Opus 5.5 committed 2026-10-18 03:13:35 -05:00
1 parent 72688f48ac
commit e0240d8e10
6 files changed
+96 -10

No files matched your search

+8 -5
View File
@@ -48,7 +48,7 @@ services:
container_name: backup_scheduler
image: alpine:3.20
restart: unless-stopped
networks: [backup]
networks: [backup, edge] # edge: push heartbeats to uptime_kuma:3001
env_file:
- stack.env
volumes:
@@ -56,14 +56,17 @@ services:
- /config/backup/dumps:/dumps
- /config/backup/scripts/backup-dump-databases.sh:/scripts/backup-dump-databases.sh:ro
- /config/backup/scripts/backup-run-snapshots.sh:/scripts/backup-run-snapshots.sh:ro
- /config/backup/scripts/backup-check-freshness.sh:/scripts/backup-check-freshness.sh:ro
- /config/backup/snapshot-paths.txt:/snapshot-paths.txt:ro
- /config/backup/crontab:/etc/crontab:ro
# busybox crond reads <dir>/<user>; mounting at /etc/crontab meant no job ever ran
- /config/backup/crontab:/etc/crontabs/root:ro
entrypoint: ["/bin/sh", "-c"]
command:
- |
apk add --no-cache docker-cli curl tzdata >/dev/null
printenv | grep -E '^(NTFY_|TZ=)' > /etc/backup.env || true
crond -f -l 8 -c /etc
apk add --no-cache docker-cli curl jq tzdata >/dev/null
# crond jobs get a bare env; scripts source this instead
printenv | grep -E '^(NTFY_|KUMA_|KOPIA_REPOSITORY_PASSWORD=|TZ=)' | sed "s/=\(.*\)/='\1'/" > /etc/backup.env || true
crond -f -l 8 -c /etc/crontabs
depends_on:
- kopia