Correction mount backup

This commit is contained in:
admin666 2023-11-21 23:09:59 +01:00
parent d4c2027c82
commit 8ad79d1787
1 changed files with 4 additions and 20 deletions

View File

@ -24,27 +24,19 @@ trap clean_exit INT
function clean_exit() {
echo "Exiting..."
umount -q /mnt/${vm}
umount -q /mnt/${vm}-remote
sync
if [ ! -z ${loopdisk} ]; then
losetup -d ${loopdisk}
fi
sleep 3
rmdir /mnt${vm}*
rmdir /mnt${vm}-remote
}
vm=$1
dest=$2
backuphost=$3
backuphost=$2
generic_image="/srv/vmverse/installation/generic.a-lec.org.raw"
if [[ $# != 3 ]]
if [[ $# != 2 ]]
then
echo "ERROR: 3 parameters required : vm domain, destination path, backup host"
echo "ERROR: 2 parameters required : vm domain, backup host"
exit 1
fi
@ -71,18 +63,10 @@ echo -e "\nOK\n"
# Preparing path
echo "Preparing path..."
mkdir -p /mnt/${vm}
mkdir -p /mnt/${vm}-remote
mkdir -p $(dirname ${dest})
# Creating new disk
echo "Creating new disk..."
cp --reflink ${generic_image} ${dest}
# Mounting
echo "Mounting devices..."
loopdisk=$(losetup -fPL ${dest} --show)
mount ${loopdisk}p1 /mnt/${vm}
borg mount root@${backuphost}:/var/backups/borg/${vm}.repo::${DATES[backupdate]} /mnt/${vm}-remote
# Syncing