Skip to content

Commit

Permalink
safer, but untested volume rename util
Browse files Browse the repository at this point in the history
  • Loading branch information
wscherphof committed Sep 9, 2022
1 parent e05b7f3 commit c8f2999
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions utils/docker-volume-rename.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/bin/bash
set -e

export MSYS_NO_PATHCONV=1

src_volume=$1
dst_volume=$2

docker volume create "${dst_volume}" >/dev/null
docker volume create "${dst_volume}"

docker container run \
--name docker-volume-mv \
Expand All @@ -14,13 +15,8 @@ docker container run \
--mount source="${dst_volume}",target=/.dst \
alpine \
sh -c ' # https://unix.stackexchange.com/a/6397
for x in /.src/* /.src/.[!.]* /.src/..?*
do
if [ -e "$x" ]
then
mv -- "$x" /.dst/
fi
done
shopt -s dotglob
mv /.src/* /.dst/
'

if ! docker volume rm "${src_volume}" >/dev/null; then
Expand Down

0 comments on commit c8f2999

Please sign in to comment.