Created
March 19, 2017 23:26
-
-
Save DALDEI/22f3d05c7a875699a443e056b61dd860 to your computer and use it in GitHub Desktop.
Backup/Restore Docker Volumes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# backup files from a docker volume into /tmp/backup.tar.gz | |
# from http://stackoverflow.com/questions/21597463/how-to-port-data-only-volumes-from-one-host-to-another | |
function docker-volume-backup-compressed() { | |
docker run --rm -v /tmp:/backup --volumes-from "$1" debian:jessie tar -czvf /backup/backup.tar.gz "${@:2}" | |
} | |
# restore files from /tmp/backup.tar.gz into a docker volume | |
function docker-volume-restore-compressed() { | |
docker run --rm -v /tmp:/backup --volumes-from "$1" debian:jessie tar -xzvf /backup/backup.tar.gz "${@:2}" | |
echo "Double checking files..." | |
docker run --rm -v /tmp:/backup --volumes-from "$1" debian:jessie ls -lh "${@:2}" | |
} | |
# backup files from a docker volume into /tmp/backup.tar | |
function docker-volume-backup() { | |
docker run --rm -v /tmp:/backup --volumes-from "$1" busybox tar -cvf /backup/backup.tar "${@:2}" | |
} | |
# restore files from /tmp/backup.tar into a docker volume | |
function docker-volume-restore() { | |
docker run --rm -v /tmp:/backup --volumes-from "$1" busybox tar -xvf /backup/backup.tar "${@:2}" | |
echo "Double checking files..." | |
docker run --rm -v /tmp:/backup --volumes-from "$1" busybox ls -lh "${@:2}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Copied from http://stackoverflow.com/questions/21597463/how-to-port-data-only-volumes-from-one-host-to-another