Skip to content

Instantly share code, notes, and snippets.

@jaybuidl
Created January 10, 2017 10:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaybuidl/24c480677a0fec29ba0a9c1c9278ea4a to your computer and use it in GitHub Desktop.
Save jaybuidl/24c480677a0fec29ba0a9c1c9278ea4a to your computer and use it in GitHub Desktop.
Copies all the local docker data volumes to a new machine via ssh
#/!bin/bash
[ $# -lt 1 ] && echo "usage: $(basename $0) <target_ssh_user@target_ssh_hostname>" && exit 1;
target="$1"
docker pull alpine
for volume in $(docker volume ls -q)
do
docker run --rm -v $volume:/from alpine ash -c "cd /from ; tar -cf - . " \
ssh $target 'docker run --rm -i -v '$volume':/to alpine ash -c "cd /to ; tar -xvf - " '
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment