Skip to main content

Backup Docker volumes to local with rsync and optional DB dumps.

Project description

baudolo โ€“ Deterministic Backup & Restore for Docker Volumes ๐Ÿ“ฆ๐Ÿ”„

GitHub Sponsors Patreon Buy Me a Coffee PayPal License: AGPL v3 Docker Version Python Version GitHub stars

baudolo is a backup and restore system for Docker volumes with mandatory file backups and explicit, deterministic database dumps. It is designed for environments with many Docker services where:

  • file-level backups must always exist
  • database dumps must be intentional, predictable, and auditable

โœจ Key Features

  • ๐Ÿ“ฆ Incremental Docker volume backups using rsync --link-dest
  • ๐Ÿ—„ Optional SQL dumps for:
    • PostgreSQL
    • MariaDB / MySQL
  • ๐ŸŒฑ Explicit database definition for SQL backups (no auto-discovery)
  • ๐Ÿงพ Backup integrity stamping via dirval (Python API)
  • โธ Automatic container stop/start when required for consistency
  • ๐Ÿšซ Whitelisting of containers that do not require stopping
  • โ™ป๏ธ Modular, maintainable Python architecture

๐Ÿง  Core Concept (Important!)

baudolo separates file backups from database dumps.

  • Docker volumes are always backed up at file level
  • SQL dumps are created only for explicitly defined databases

This results in the following behavior:

Database defined File backup SQL dump
No โœ” yes โœ˜ no
Yes โœ” yes โœ” yes

๐Ÿ“ Backup Layout

Backups are stored in a deterministic, fully nested structure:

<backups-dir>/
โ””โ”€โ”€ <machine-hash>/
    โ””โ”€โ”€ <repo-name>/
        โ””โ”€โ”€ <timestamp>/
            โ””โ”€โ”€ <volume-name>/
                โ”œโ”€โ”€ files/
                โ””โ”€โ”€ sql/
                    โ””โ”€โ”€ <database>.backup.sql

Meaning of each level

  • <machine-hash> SHA256 hash of /etc/machine-id (host separation)

  • <repo-name> Logical backup namespace (project / stack)

  • <timestamp> Backup generation (YYYYMMDDHHMMSS)

  • <volume-name> Docker volume name

  • files/ Incremental file backup (rsync)

  • sql/ Optional SQL dumps (only for defined databases)

๐Ÿš€ Installation

Local (editable install)

python3 -m venv .venv
source .venv/bin/activate
pip install -e .

๐ŸŒฑ Database Definition (SQL Backup Scope)

How SQL backups are defined

baudolo creates SQL dumps only for databases that are explicitly defined via configuration (e.g. a databases definition file or seeding step).

If a database is not defined:

  • its Docker volume is still backed up (files)
  • no SQL dump is created

No database definition โ†’ file backup only Database definition present โ†’ file backup + SQL dump

Why explicit definition?

baudolo does not inspect running containers to guess databases.

Databases must be explicitly defined to guarantee:

  • deterministic backups
  • predictable restore behavior
  • reproducible environments
  • zero accidental production data exposure

Required database metadata

Each database definition provides:

  • database instance (container or logical instance)
  • database name
  • database user
  • database password

This information is used by baudolo to execute pg_dump, pg_dumpall, or mariadb-dump.

๐Ÿ’พ Running a Backup

baudolo \
  --compose-dir /srv/docker \
  --databases-csv /etc/baudolo/databases.csv \
  --database-containers central-postgres central-mariadb \
  --images-no-stop-required alpine postgres mariadb mysql \
  --images-no-backup-required redis busybox

Common Backup Flags

Flag Description
--everything Always stop containers and re-run rsync
--dump-only-sql Skip file backups only for DB volumes when dumps succeed; non-DB volumes are still backed up; fallback to files if no dump.
--shutdown Do not restart containers after backup
--backups-dir Backup root directory (default: /Backups)
--repo-name Backup namespace under machine hash

โ™ป๏ธ Restore Operations

Restore Volume Files

baudolo-restore files \
  my-volume \
  <machine-hash> \
  <version> \
  --backups-dir /Backups \
  --repo-name my-repo

Restore into a different target volume:

baudolo-restore files \
  target-volume \
  <machine-hash> \
  <version> \
  --source-volume source-volume

Restore PostgreSQL

baudolo-restore postgres \
  my-volume \
  <machine-hash> \
  <version> \
  --container postgres \
  --db-name appdb \
  --db-password secret \
  --empty

Restore MariaDB / MySQL

baudolo-restore mariadb \
  my-volume \
  <machine-hash> \
  <version> \
  --container mariadb \
  --db-name shopdb \
  --db-password secret \
  --empty

baudolo automatically detects whether mariadb or mysql is available inside the container

๐Ÿ” Backup Scheme

The backup mechanism uses incremental backups with rsync and stamps directories with a unique hash. For more details on the backup scheme, check out this blog post.
Backup Scheme

๐Ÿ‘จโ€๐Ÿ’ป Author

Kevin Veen-Birkenbach

๐Ÿ“œ License

This project is licensed under the GNU Affero General Public License v3.0. See the LICENSE file for details.

๐Ÿ”— More Information


Happy Backing Up! ๐Ÿš€๐Ÿ”

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

backup_docker_to_local-1.7.1.tar.gz (27.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

backup_docker_to_local-1.7.1-py3-none-any.whl (32.5 kB view details)

Uploaded Python 3

File details

Details for the file backup_docker_to_local-1.7.1.tar.gz.

File metadata

  • Download URL: backup_docker_to_local-1.7.1.tar.gz
  • Upload date:
  • Size: 27.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for backup_docker_to_local-1.7.1.tar.gz
Algorithm Hash digest
SHA256 f4abd98bcffd0e0c40f50dcc48a48c786a38a940f4330878819755a4ef98d99d
MD5 362c20aedb9fc4ae293353381288021d
BLAKE2b-256 65b0df6e606297aeeaf543aa0bff49cec7c517955c8d8b06c37f20f4879c61e9

See more details on using hashes here.

File details

Details for the file backup_docker_to_local-1.7.1-py3-none-any.whl.

File metadata

File hashes

Hashes for backup_docker_to_local-1.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d932cd895ba6bfa331b018783b524011d952b713618ee18cad664b7eb6cef17b
MD5 179f32950dc5cc04e5b1ad8db4cd7e45
BLAKE2b-256 bec0ef00cbb493d09be08f499ea2f4d035b9dad0c10c1f009d80a62e7167a32a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page