Created
November 26, 2018 20:56
-
-
Save mminer/5950d83218e0d3f9ceb151c648add7ed to your computer and use it in GitHub Desktop.
Restores Docker volumes from tar archives.
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
#!/usr/bin/env bash | |
usage() { | |
cat <<EOF | |
Usage: $0 VOLUME [VOLUME ...] | |
Restore Docker volumes from tar archives. | |
EOF | |
} | |
if (( $# < 1 )); then | |
usage | |
exit 1 | |
fi | |
for volume in "$@"; do | |
docker run --rm --volume=${volume}:/data --volume=$(pwd):/backup:ro ubuntu \ | |
bash -c "cd /data && tar xf /backup/${volume}.tar --strip 1" \ | |
&& echo "Restored volume ${volume} from ${volume}.tar" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment