Nautical Backup is a Docker-based container backup tool that automatically backs up Docker container data using rsync. It is configured via Docker labels on individual containers or via environment variables on the Nautical container itself.
- GitHub: https://github.com/Minituff/nautical-backup
- Language: Python (FastAPI backend, rsync for file transfer)
- Distribution: Docker image (
minituff/nautical-backup)
~10,000 users run this app, many with auto-updating Docker containers. A push to the main branch can trigger automatic updates for a significant portion of the user base within hours.
- Every code change must be reviewed for backward compatibility before merging.
- If a change breaks existing behavior, it must be called out explicitly in the PR and the version bumped using semantic versioning (semver):
PATCH(x.x.1) — bug fixes, no behavior change for existing usersMINOR(x.1.x) — new features, fully backward-compatibleMAJOR(1.x.x) — breaking changes (avoid unless absolutely necessary)
The docs/ folder contains the MkDocs user-facing documentation. Read the relevant docs pages before implementing any feature or fix. If the docs describe a behavior, that behavior is the contract with users. If your change affects documented behavior, update the docs too.
Key docs pages:
docs/labels.md— all Docker label options (per-container config)docs/arguments.md— all environment variable options (global config)docs/introduction.md— high-level overviewapp/defaults.env— default environment variable values
Tests in pytest/ exist to enforce backward compatibility. Treat them as a contract.
- Do not modify existing tests unless there is a clear, meaningful reason (e.g., the test was wrong, or the code behavior intentionally changed).
- If you must change an existing test, call it out explicitly when proposing or describing the change.
- Adding new tests is always fine and encouraged.
- When mocking
subprocess.run, always setmock_subprocess_run.return_value.returncode = 0in new tests so the mock behaves like a successful rsync call.
Run tests with: nb pytest (inside the dev environment) or python -m pytest pytest/ locally (excluding pytest/test_api.py if the dev DB is not initialized).
- Bash init scripts duplicate Python logic.
app/entry.sh,env.sh,logger.sh, andutils.shrun during s6-overlay container init, before the Python app starts, and some of them re-implement logic that also exists in Python (e.g.logger.sh's report-file naming mirrorslogger.py). If you change one side, update the other and keep them in sync. There is no bash test framework in this repo (no bats/shellcheck), sopytest/never exercises the bash side — verify bash changes manually (bash -n script.shat minimum; ideally build the image and run it for real). nb pytesttouches real shared dev state, not isolated temp dirs —test_backup.py's retention-policy tests read/write the actualdev/config/nautical-db.json,dev/destination, anddev/source. Don't runnb pytestin two terminals/processes at once; it races on these files and produces spuriousJSONDecodeError/Directory not emptyfailures that look like a real regression but aren't.nb integrationneeds a manual pre-step. It runsdocker composeagainst aminituff/nautical-testimage it never builds itself (that step is commented out in.devcontainer/scripts/nb.sh). Build it first withdocker build --build-arg TEST_MODE=0 -t minituff/nautical-test ., matching the separate build step in.github/workflows/test_docker_image.yml.
app/
backup.py # Core backup orchestration (NauticalBackup class)
nautical_env.py # Environment variable parsing (NauticalEnv class)
api/ # FastAPI REST API
db.py # Simple JSON key-value database
logger.py # Logging utilities
pytest/ # Test suite
docs/ # MkDocs user documentation