diff --git a/Backup/.Backup_HD_1TB.sh b/Backup/.Backup_HD_1TB.sh index a2ad1a6..eff9c9e 100755 --- a/Backup/.Backup_HD_1TB.sh +++ b/Backup/.Backup_HD_1TB.sh @@ -1,16 +1,20 @@ YEARMONTH=`date +%Y/%m-%b` YEAR=`date +%Y` -HDPath="/run/media/bruno/Seagate" +HDPath="/run/media/bruno/Backup_" +LastDisk=$(< .lastDisk) + +if [ "$LastDisk" = '1' ]; then + NextDisk=2 +else + NextDisk=1 +fi + +backup="rsync -aq --inplace --exclude-from=./exclude" +HDPath="$HDPath$NextDisk" HDYEARMONTH="$HDPath/$YEARMONTH" -mkdir -p "$HDPath/$YEAR" -mkdir -p "$HDYEARMONTH" -mkdir -p "$HDYEARMONTH/LinuxHome" -mkdir -p "$HDYEARMONTH/LinuxHome/bruno" -mkdir -p "$HDYEARMONTH/LinuxHome/admin" -mkdir -p "$HDYEARMONTH/LinuxHome/lost+found" - -backup="rsync -rptgoDql --exclude-from=./exclude" +# If folder does not exist, exit with error +[ ! -d "$HDPath" ] && echo "This disk was used last time. Please, plug Backup_$NextDisk before running this script." && exit 1 echo echo "Backup command : $backup" @@ -21,6 +25,14 @@ echo Press enter key to start the backup read echo +mkdir -p "$HDPath/$YEAR" +mkdir -p "$HDYEARMONTH" +mkdir -p "$HDYEARMONTH/LinuxHome" +mkdir -p "$HDYEARMONTH/LinuxHome/bruno" +mkdir -p "$HDYEARMONTH/LinuxHome/admin" +mkdir -p "$HDYEARMONTH/LinuxHome/lost+found" + + echo -e "\e[97m`date +%r` - Copying Dropbox folder (1/7)...\e[39m" eval $backup "/run/media/bruno/Multimedia/Dropbox" "$HDYEARMONTH/Multimedia/" || echo "" @@ -52,4 +64,5 @@ eval $backup "/run/media/bruno/Multimedia/Virtual\ Machines" "$HDPath/$YEAR/" || echo -e "\e[97m`date +%r` - Backup finished. Please, verify your log files.\e[39m" +echo "$NextDisk" > .lastDisk kdialog --title "Backup Complete" --msgbox "Backup finished successfully" diff --git a/Backup/.lastDisk b/Backup/.lastDisk new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Backup/.lastDisk @@ -0,0 +1 @@ +1 diff --git a/Backup/exclude b/Backup/exclude index 6a5c148..13610e8 100755 --- a/Backup/exclude +++ b/Backup/exclude @@ -3,3 +3,4 @@ Downloads/* TransMit\ Tools\ -\ Studio\ 2015/* Apps/* shared/* +.npm/*