Backup Docker Volumes to Local (baudolo) 📦🔄

GitHub Sponsors Patreon Buy Me a Coffee PayPal

Backup Docker Volumes to Local is a set of Python and shell scripts that enable you to perform incremental backups of all your Docker volumes using rsync. It is designed to integrate seamlessly with Kevin's Package Manager under the alias baudolo, making it easy to install and manage. The tool supports both file and database recoveries with a clear, automated backup scheme.

License: AGPL v3 Docker Version Python Version GitHub stars

🎯 Goal

This project automates the backup of Docker volumes using incremental backups (rsync) and supports recovering both files and database dumps (MariaDB/PostgreSQL). A robust directory stamping mechanism ensures data integrity, and the tool also handles restarting Docker Compose services when necessary.

🚀 Features

  • Incremental Backups: Uses rsync with --link-dest for efficient, versioned backups.
  • Database Backup Support: Backs up MariaDB and PostgreSQL databases from running containers.
  • Volume Recovery: Provides scripts to recover volumes and databases from backups.
  • Docker Compose Integration: Option to automatically restart Docker Compose services after backup.
  • Flexible Configuration: Easily integrated with your Docker environment with minimal setup.
  • Comprehensive Logging: Detailed command output and error handling for safe operations.

🛠 Requirements

  • Linux Operating System (with Docker installed) 🐧
  • Python 3.x 🐍
  • Docker & Docker Compose 🔧
  • rsync installed on your system

📥 Installation

You can install Backup Docker Volumes to Local easily via Kevin's Package Manager using the alias baudolo:

pkgman install baudolo

Alternatively, clone the repository directly:

git clone https://github.com/kevinveenbirkenbach/backup-docker-to-local.git
cd backup-docker-to-local

🚀 Usage

Backup All Volumes

To backup all Docker volumes, simply run:

./backup-docker-to-local.sh

Recovery

Recover Volume Files

bash ./recover-docker-from-local.sh "{{volume_name}}" "$(sha256sum /etc/machine-id | head -c 64)" "{{version_to_recover}}"

Recover Database

For example, to recover a MySQL/MariaDB database:

docker exec -i mysql_container mysql -uroot -psecret database < db.sql

Debug Mode

To inspect whats happening inside a container:

docker run -it --entrypoint /bin/sh --rm --volumes-from {{container_name}} -v /Backups/:/Backups/ kevinveenbirkenbach/alpine-rsync

🔍 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

🧑‍💻 Setup & Dependencies

Make sure you have pandas installed:

pip install pandas

Also, ensure your system meets all the requirements listed above.

👨‍💻 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! 🚀🔐

Description
contains scripts to manage docker
Readme AGPL-3.0 359 KiB
Languages
Python 85.7%
Shell 14.1%
Smarty 0.2%