Files
compose-backup/README.md
2025-07-20 12:47:48 +02:00

2.6 KiB
Raw Blame History

🐳 Compose Backup & Restore Tool

A simple backup & restore tool for Docker Compose projects, including volume data.
Ideal for migrating projects or creating point-in-time snapshots of your stack.


📦 Features

  • 🔐 Full backup of your Docker Compose project folder
  • 💾 Archives all named Docker volumes (excluding bind-mounts)
  • 🧠 Automatic project detection and naming
  • 🧙 Interactive restore menu with project/version selection
  • ☁️ Stores backups in ~/.compose-backup
  • 🐍 Uses Python + Docker + Bash (no external services)

📁 Project Structure


compose-backup/
├── bin/
│   ├── compose-backup      # Bash launcher (patched on install)
│   └── compose-restore     # Bash launcher (patched on install)
├── src/
│   ├── backup.py           # Backup logic
│   └── restore.py          # Restore logic
├── requirements.txt
├── install.sh              # Install script (creates venv & installs commands)
└── README.md


🚀 Installation

git clone https://your.repo/compose-backup.git
cd compose-backup
./install.sh

This will:

  • Set up a virtual environment in .venv
  • Install required Python packages
  • Patch & install compose-backup and compose-restore to /usr/local/bin

🔒 Youll be prompted for your sudo password to copy binaries system-wide.


🔁 Usage

📤 Backup

From inside a folder containing your docker-compose.yml:

compose-backup

Creates a full backup (project files + named volumes) into:

~/.compose-backup/
└── myproject_backup_20250711_183012.tar.gz

📥 Restore

To restore a backup, anywhere on your system:

compose-restore
  • Step 1: Choose project
  • Step 2: Choose version
  • Step 3: Project files are restored to your current folder
  • Step 4: Volumes are restored via temporary containers

🧼 Uninstall

To remove installed commands:

sudo rm /usr/local/bin/compose-backup /usr/local/bin/compose-restore

(Optional) remove .venv and the repo folder.


🛠 Requirements

  • Docker
  • Python 3.8+
  • Linux or macOS (tested on Ubuntu)

📌 Notes

  • Only named volumes (declared under volumes: in your docker-compose.yml) are backed up.
  • Bind mounts like ./data:/app/data are not included.
  • The tool does not stop running containers before backup — ensure consistency manually if needed.

🤝 License

MIT — feel free to fork and improve!


👨‍💻 Author

Built by gmarth — Contributions welcome!