An utility to backup and restore docker volumes using rdiff-backup
Note: Make sure no container is using the volume before backup or restore, otherwise your data might be damaged. See Miscellaneous for instructions.
docker image build -t vbackup:1.0 .
docker run -v [volume-name]:/volume -v [backup-dir]:/backup --rm vbackup:1.0 backup
-r rdiff-backup restore-as-of variable. Must be used with restore
docker run -v [volume-name]:/volume -v [backup-dir]:/backup --rm vbackup:1.0 restore -r 10D
-t rdiff-backup remove-older-than variable. Must be used with remote
docker run -v [volume-name]:/volume -v [backup-dir]:/backup --rm vbackup:1.0 remote -t 20B
- Find and pause all containers using a volume (to stop them before backing-up)
docker ps -a --filter volume=[volume-name] -q | while read x ; do docker pause $x ; done
- Find and unpause all containers using a volume
docker ps -a --filter volume=[volume-name] -q | while read x ; do docker unpause $x ; done