41 lines
766 B
Bash
Executable File
41 lines
766 B
Bash
Executable File
#!/bin/bash
|
|
|
|
#set -o xtrace
|
|
|
|
PREFIX=""
|
|
if [[ -v 1 ]]; then
|
|
PREFIX="${1}_"
|
|
printf "Add prefix $PREFIX\n"
|
|
fi
|
|
|
|
cprompt () {
|
|
read -r -s -N 1 -p "Continue [Enter]?"
|
|
if [[ $REPLY == $'\n' ]]; then
|
|
printf "\n"
|
|
else
|
|
printf "\n"
|
|
printf " Script stopped!\n"
|
|
exit
|
|
fi
|
|
}
|
|
|
|
#pushd vtb || exit 1
|
|
for TAR in *.tar.bz2; do
|
|
if [[ $TAR =~ .tar.bz2 ]]; then
|
|
VOL=${TAR%.tar.bz2}
|
|
if [[ -n $PREFIX ]]; then
|
|
VOL="${PREFIX}${VOL#*_}"
|
|
fi
|
|
if sudo docker volume ls -q |grep -qw "${VOL}"; then
|
|
printf "Operation: ${TAR} -> ${VOL}\n"
|
|
cprompt
|
|
sudo cat "${TAR}" \
|
|
|sudo docker run -i -v "${VOL}:/volume" --rm \
|
|
loomchild/volume-backup restore -v -f - || exit 3
|
|
fi
|
|
fi
|
|
done
|
|
#popd || exit 1
|
|
|
|
set +o xtrace
|