change cp with tar

This commit is contained in:
Alexey Ukhov 2020-03-24 10:20:53 +07:00
parent ba21581030
commit 1e9a58a799

6
docker_clone_volume.sh Normal file → Executable file
View file

@ -13,7 +13,7 @@ then
exit exit
fi fi
if [ "$2" = "" ] if [ "$2" = "" ]
then then
echo "Please provide a destination volume name" echo "Please provide a destination volume name"
exit exit
@ -40,11 +40,11 @@ fi
echo "Creating destination volume \"$2\"..." echo "Creating destination volume \"$2\"..."
docker volume create --name $2 docker volume create --name $2
echo "Copying data from source volume \"$1\" to destination volume \"$2\"..." echo "Copying data from source volume \"$1\" to destination volume \"$2\"..."
docker run --rm \ docker run --rm \
-i \ -i \
-t \ -t \
-v $1:/from \ -v $1:/from \
-v $2:/to \ -v $2:/to \
alpine ash -c "cd /from ; cp -av . /to" alpine ash -c "cd /from && tar cf - . | (cd /to && tar xvf -)"