Improving the script to use 2 HDs

This commit is contained in:
Bruno F. Fontes 2019-07-19 15:54:14 -03:00
parent a4808a0e61
commit 5799d5a332
Signed by: brunofontes
GPG Key ID: EE3447CE80048495
3 changed files with 24 additions and 9 deletions

View File

@ -1,16 +1,20 @@
YEARMONTH=`date +%Y/%m-%b` YEARMONTH=`date +%Y/%m-%b`
YEAR=`date +%Y` 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" HDYEARMONTH="$HDPath/$YEARMONTH"
mkdir -p "$HDPath/$YEAR" # If folder does not exist, exit with error
mkdir -p "$HDYEARMONTH" [ ! -d "$HDPath" ] && echo "This disk was used last time. Please, plug Backup_$NextDisk before running this script." && exit 1
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"
echo echo
echo "Backup command : $backup" echo "Backup command : $backup"
@ -21,6 +25,14 @@ echo Press enter key to start the backup
read read
echo 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" echo -e "\e[97m`date +%r` - Copying Dropbox folder (1/7)...\e[39m"
eval $backup "/run/media/bruno/Multimedia/Dropbox" "$HDYEARMONTH/Multimedia/" || echo "" 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 -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" kdialog --title "Backup Complete" --msgbox "Backup finished successfully"

1
Backup/.lastDisk Normal file
View File

@ -0,0 +1 @@
1

View File

@ -3,3 +3,4 @@ Downloads/*
TransMit\ Tools\ -\ Studio\ 2015/* TransMit\ Tools\ -\ Studio\ 2015/*
Apps/* Apps/*
shared/* shared/*
.npm/*