A backup script for my docker compose stack
Find a file
Jon Dahl a95d5805dc Emit maintenance marker during daily backup window
The daily backup stops and restarts media containers for a consistent
snapshot, which previously tripped the deep media checks and their
failure alerting every night. Write a local maintenance marker at the
start of the daily run, refresh it as each stack is processed, and
remove it when the run finishes. The media checks read the marker's
mtime and skip their run while it is fresh, so the planned downtime
window no longer generates false alerts.
2026-10-02 19:50:30 +00:00
tests Add safe backup retention reporting 2026-09-03 07:17:39 +00:00
.gitignore Add ntfy backup notifications 2026-06-07 04:19:06 +02:00
docker-stack-backup.py Emit maintenance marker during daily backup window 2026-10-02 19:50:30 +00:00
LICENSE Initial commit 2026-04-24 18:48:58 +02:00
README.md Add safe backup retention reporting 2026-09-03 07:17:39 +00:00

docker-stack-backup

Back up Docker Compose definitions and appdata to a remote host with hardlink deduplication between snapshots.

Retention

The retention policy keeps the union of:

  • 14 newest daily snapshots
  • newest snapshot in each of the latest 8 ISO weeks
  • newest snapshot in each of the latest 12 represented calendar months
  • 8 newest snapshots in each generated-media series

Manual and emergency namespaces are never considered because retention only accepts timestamp-shaped direct children of configured backup directories. Future backups receive an incomplete marker when they start and an atomic JSON completion marker when they finish. Incomplete snapshots are always retained.

Report all scopes without running a backup:

python3 docker-stack-backup.py \
  --retention-only \
  --retention-mode report \
  --retention-scope all

Run a normal daily backup followed by a retention report:

python3 docker-stack-backup.py --retention-mode report

--retention-mode apply is accepted only following a successful backup in the same locked process. Standalone apply is deliberately rejected. Apply mode must not be enabled until a fresh report has been reviewed and deletion approved.

Tests

python3 -m unittest discover -s tests -v