From ff2c5ccf1f016e7b368e21c8a71b490745c0aa9a Mon Sep 17 00:00:00 2001 From: Jack-Benny Persson Date: Wed, 18 Dec 2013 12:02:31 +0100 Subject: [PATCH] Finished script --- Labb5/serverbackup/serverbackup.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Labb5/serverbackup/serverbackup.sh b/Labb5/serverbackup/serverbackup.sh index a73d2d1..befb87f 100755 --- a/Labb5/serverbackup/serverbackup.sh +++ b/Labb5/serverbackup/serverbackup.sh @@ -6,7 +6,7 @@ ## Variables ## # Define some settings for the script -BackupDir="dummyfiles" # This is were Proxmos places it's backup files +BackupDir="dummyfiles" # This is were Proxmox places it's backup files TapeDev="/dev/st0" # The device for your Tape drive ExtHDD="/dev/sdd1" # The external harddrive MntPoint="/mnt" # Where to mount the external harddrive @@ -105,7 +105,13 @@ if [ "$Where" = "HDD" ] || [ "$Where" = "Tape&HDD" ]; then #$Ls vzdump-*-${VMs}-${Latest}* # and debugging # Create a separate directory for each backup and copy the files + if [ -d ${MntPoint}/${ExtHDDdir}/${Latest} ]; then + printf "${MntPoint}/${ExtHDDdir}/${Latest} already exist, " + printf "aborting\n" > /dev/stderr + exit 2 + fi $Mkdir ${MntPoint}/${ExtHDDdir}/${Latest} + echo "Copying files to $ExtHDD" $Cp -v vzdump-*-${VMs}-${Latest}* ${MntPoint}/${ExtHDDdir}/${Latest} if [ $? -ne 0 ]; then @@ -124,6 +130,8 @@ fi if [ "$Where" = "Tape" ] || [ "$Where" = "Tape&HDD" ]; then #echo "Backup to tape drive $TapeDev" # Uncomment for testing #$Ls vzdump-*-${VMs}-${Latest}* # and debugging + echo "" + echo "Writing tape backup" tar cvf $TapeDev vzdump-*-${VMs}-${Latest}* if [ $? -ne 0 ]; then