Repository navigation
Containerized MariaDB/PostgreSQL/MongoDB backup tool - #1
Merged
Merged
Conversation
A single image, run as a Kubernetes CronJob (or with Docker), that makes logical backups of any number of MariaDB, PostgreSQL and MongoDB servers onto a shared filesystem, with GFS retention and MQTT status reporting. - Enumerates every database per server (with include/exclude), and saves server-level objects: PG roles/tablespaces, MariaDB users/grants, MongoDB users/roles (whole-instance mongodump --oplog). - Sets are written to .partial, verified, checksummed into a manifest and renamed into place; finished sets are never modified, so off-site sync only sees new files. - GFS retention (daily/weekly/monthly/yearly/last), applied only after a target's own backup succeeds; the newest good set is always kept. - Per-target isolation, retries and locking; non-zero exit on any failure. - MQTT retained status with Home Assistant discovery, for Alert Redux failure and staleness (dead man's switch) alerts. - dbbackup restore, which leaves accounts that already exist on the destination untouched; plus a stock-tools DR runbook. - Secrets only via env vars or files, never on argv. - Kustomize base (CronJob, NFS PV/PVC, ConfigMap), compose test stack, unit and integration tests, and GitHub Actions CI with GHCR publishing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A single image that makes logical disaster-recovery backups of any number of MariaDB, PostgreSQL and MongoDB servers onto an NFS share. It runs as a Kubernetes CronJob, or with Docker for testing. Retention is grandfather-father-son, and status goes out over MQTT.
pg_dumpall --globals-only)mariadb-dump --system=users)mongodump --oplog, consistent to a point in time).partialdirectory, verified, given a manifest with SHA-256 checksums, and renamed into place. Finished sets are never renamed or modified, so the off-site sync only ever uploads new files.daily/weekly/monthly/yearly/last). A target is pruned only after its own backup succeeds, and its newest good set is always kept.docs/home-assistant.mdsets up two Alert Redux generators: Backup failed, and Backup stale, which acts as a dead man's switch.dbbackup restoreleaves accounts that already exist on the destination untouched, including the restoring account and a fresh container's ownroot/healthcheck.docs/restore.mdis a DR runbook that needs only stock tools.Design notes from testing against real servers
pg_read_all_datacan readpg_authid, so the PostgreSQL backup role saves role password hashes without being a superuser.mongodumphas no--nsExclude, so a MongoDB target with include/exclude gets per-database dumps without--oplog. The manifest records a warning about the lost point-in-time consistency.mongorestore --dropalso replaces existing users, and--oplogReplaycan't be combined with namespace excludes.--forcetherefore drops the clashing databases through the driver and never passes--drop.Test plan
make lintandmake test: 76 unit testsmake integrationon a fresh compose stack: 17 end-to-end tests covering backup, manifests, verify/list, MQTT and discovery, restores of all three engines (data, users, passwords, grants, routines/triggers/events, views, indexes), refusal without--force, same-day pruning, locking and corruption detectionkubectl apply --dry-run=client -k deploy/k8skubectl -n db-backup create job --from=cronjob/db-backup db-backup-manualPhase 2, a local Docker-based restore test, comes later. The manifest inventory it will check against is already recorded.
🤖 Generated with Claude Code