Live2026

Mongo Backup S3

Small Alpine Docker image that backs up and restores MongoDB to any S3-compatible store (AWS S3, Backblaze B2, Cloudflare R2, MinIO, Wasabi), with age-based or grandfather-father-son retention. Driven by your existing cron.

Mongo Backup S3

Problem solved

Most MongoDB backup setups are a hand-rolled shell script that pipes mongodump somewhere and reports success no matter what. The failure modes are silent: a dump that dies mid-stream still uploads a truncated archive, an empty database (typo'd name, wrong host) produces a valid tiny archive that "succeeds" nightly, and a naive retention script eventually deletes the last surviving backup after the cron that creates new ones silently breaks. You find out on the day you need to restore.

Value proposition

One small Docker image with five commands: backup, restore, list, prune, thin. Every known failure mode is either guarded (truncated uploads are detected and removed, undersized archives fail the run, the newest backup is never deleted, a mistyped retention value aborts instead of mass-deleting) or documented honestly in the README as a limitation you must read. Retention is either a simple age cutoff or grandfather-father-son thinning: with tiers set to 24 hourly, 7 daily, 4 weekly, and 12 monthly, a year of hourly backups collapses to about 47 copies instead of 8,760. It works with any S3-compatible store and has no scheduler of its own: your existing cron, systemd timer, or Kubernetes CronJob drives it.

Target audience

Self-hosters, freelances, and small teams running MongoDB in Docker who want offsite backups without adopting a heavyweight backup platform, and who care that the tool fails loudly instead of pretending.

Tech stack

  • One POSIX shell script (~400 lines), no dependencies beyond aws-cli and mongodb-tools
  • Alpine-based Docker image, multi-arch (linux/amd64 and linux/arm64), published on GHCR
  • Acceptance test suite running against real mongo and MinIO containers, including fault injection for mid-stream dump failures
  • GitHub Actions for CI; tag-driven releases where the tag is the version

Status

Live and GPL-3.0 licensed. Code generated with Claude Code, then tested and reviewed manually. Every guard in the script exists because of a real failure mode and has a test that can actually fail. Open to issues and PRs.