Alexey A. Ukhov 2020-10-27 01:05:57 +03:00 zatwierdzone przez GitHub
commit b11caeefc4
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 37 dodań i 3 usunięć

Wyświetl plik

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

Wyświetl plik

@ -0,0 +1,34 @@
#!/usr/bin/env bash
# Author: Alexey Ukhov <alex@ukhov.ru>
SCRIPTSRC=`readlink -f "$0" || echo "$0"`
SCRIPT_PATH=`dirname "$SCRIPTSRC" || echo .`
#First check if the user provided all needed arguments
if [ "$1" = "" ]
then
echo "Please provide a source volume name"
exit
fi
#Check if the source volume name does exist
docker volume inspect $1 > /dev/null 2>&1
if [ "$?" != "0" ]
then
echo "The source volume \"$1\" does not exist"
exit
fi
BACKUP_FOLDER=${2:-backup}
if [ ! -d "${BACKUP_FOLDER}" ]
then
echo "Create backup folder '${BACKUP_FOLDER}'"
mkdir -p ${BACKUP_FOLDER}
fi
NOW=$(date +"%Y-%m-%d-%H-%M-%S")
BACKUP_FILE=${BACKUP_FOLDER}/$1_${NOW}.tar.gz
echo "Export volume '$1' into file '${BACKUP_FILE}'"
docker run --rm -v $1:/from alpine ash -c 'cd /from && tar -cOzf - .' > ${BACKUP_FILE}