backup utility for named volumes of your docker-compose services
Script to backup named volumes of your services from docker-compose.yml
It parses docker-compose.yml
, finds named volume, runs a little container with these volumes mounted inside (ro
) and saves it to backup file.
Little container is approximatenumber/compose-backuper.
virtualenv
:
virtualenv compose-backuper
source compose-backuper/bin/activate
pip install -r requirements.txt
(When you finish the backup, run deactivate
to deactivate virtual environment)
docker pull approximatenumber/compose-backuper
Needed arguments:
docker-compose.yml
(by default, script searches it in the current directory)
usage: compose-backup.py [-h] [-f COMPOSE_FILE] [-p PROJECT_NAME]
[-d DESTINATION]
optional arguments:
-h, --help show this help message and exit
-f COMPOSE_FILE, --compose-file COMPOSE_FILE
path to docker-compose.yml
-p PROJECT_NAME, --project-name PROJECT_NAME
project name
-d DESTINATION, --destination DESTINATION
destination directory for backups
Example:
python compose-backup.py -f ../opt/app/docker-compose.yml -p myproj -d /opt/backups/
INFO:compose-backup:jenkins-home: saving...
INFO:compose-backup:jenkins-home: saved
INFO:compose-backup:DONE! Volumes saved: 1
ls /opt/backups
myproj_jenkins-home.tar.gz
Your contributions are appreciated!