Created
March 23, 2020 08:05
-
-
Save ineentho/106c09bd847f68e357d1f62e57a867db to your computer and use it in GitHub Desktop.
Docker volume backup and restore
This file contains hidden or 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
#!/bin/sh | |
vol-backup() { | |
docker run --rm -v $1:/data -v $(pwd):/backup busybox tar cvf /backup/$1.tar /data | |
} | |
vol-restore() { | |
docker create -v $1:/data --name $1 busybox true | |
docker run --rm --volumes-from $1 -v $(pwd):/backup busybox tar xvf /backup/$1.tar | |
docker rm $1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment