mirror of
https://github.com/brunofontes/linuxShortcuts.git
synced 2024-11-24 00:50:51 +00:00
Improve backup menu removing issued alias to rsync
This commit is contained in:
parent
d651d56726
commit
3b52ad3ae3
@ -1,3 +1,5 @@
|
||||
cd /home/bruno/Apps/linuxShortcuts/Backup/
|
||||
|
||||
LastDisk=$(< .lastDisk)
|
||||
if [ "$LastDisk" = '1' ]; then
|
||||
ActiveDisk=2
|
||||
@ -12,16 +14,28 @@ ZBACKUP="$HDPath/`date +%Y-Q%q`"
|
||||
YEARMONTH=`date +%m_%b-%d`
|
||||
HDYEARMONTH="$ZBACKUP/backups/$YEARMONTH"
|
||||
|
||||
|
||||
# If folder does not exist, exit with error
|
||||
[ ! -d "$HDPath" ] && echo "This disk was used last time. Please, plug Backup_$ActiveDisk before running this script." && read && exit 1
|
||||
|
||||
echo
|
||||
echo "Disk : $ActiveDisk"
|
||||
echo "HD Backup path : $ZBACKUP"
|
||||
echo "HD Year-Month path: $HDYEARMONTH"
|
||||
echo
|
||||
echo Press enter key to start the backup
|
||||
echo "Please, insert Disk #$ActiveDisk and press enter to start backup"
|
||||
read
|
||||
|
||||
timeout=30
|
||||
echo -n "Mounting Backup_$ActiveDisk"
|
||||
device=$(mount | grep "Backup_$ActiveDisk" | cut -d " " -f1)
|
||||
while [[ "$device" != *"/dev/"* ]]; do
|
||||
[[ $timeout -lt 1 ]] && echo -e "\e[97m Timeout!\e[39m" && break
|
||||
(( timeout-- ))
|
||||
echo -n "."
|
||||
sleep 1s
|
||||
device=$(mount | grep "Backup_$ActiveDisk" | cut -d " " -f1)
|
||||
done
|
||||
|
||||
# If folder does not exist, exit with error
|
||||
[ ! -d "$HDPath" ] && echo "This disk was used last time. Please, plug Backup_$ActiveDisk before running this script." && read && exit 1
|
||||
echo ".OK!"
|
||||
echo
|
||||
|
||||
if [ ! -d "$ZBACKUP" ]; then
|
||||
@ -43,10 +57,12 @@ mkdir -p "$HDYEARMONTH"
|
||||
|
||||
function backup () {
|
||||
nice -n 19 tar c --exclude-ignore=.no-backup --add-file=.backup --exclude-from=./exclude "$1" | zbackup backup --non-encrypted --silent "$2"
|
||||
echo "`date +%r`- Checking the backup..."
|
||||
zbackup restore --silent --non-encrypted "$2" > /dev/null 2> "$2"_status
|
||||
if [[ $(cat "$2"_status) != "" ]]; then
|
||||
echo -e "\033[1;31m ERROR UNPACKING $2 \033[0m"
|
||||
fi
|
||||
echo
|
||||
}
|
||||
|
||||
echo -e "\e[97m`date +%r` - Copying Linux Home folder (1/7)...\e[39m"
|
||||
@ -70,23 +86,20 @@ backup "/run/media/bruno/Multimedia/Música/" "$HDYEARMONTH/Multimedia-musica" |
|
||||
|
||||
|
||||
# Rsync Fotos e VMs
|
||||
alias myrsync='nice -n 19 rsync -a'
|
||||
|
||||
echo -e "\e[97m`date +%r` - Copying Fotos folder (5/7)...\e[39m"
|
||||
myrsync "/run/media/bruno/Multimedia/Fotos" "$HDPath/$YEAR/" || echo ""
|
||||
nice -n 19 rsync -a "/run/media/bruno/Multimedia/Fotos" "$HDPath/$YEAR/" || echo ""
|
||||
|
||||
echo -e "\e[97m`date +%r` - Copying Video folder (6/7)...\e[39m"
|
||||
myrsync --exclude-from=/run/media/bruno/Multimedia/Videos/.no-backup "/run/media/bruno/Multimedia/Videos" "$HDPath/$YEAR/" || echo ""
|
||||
nice -n 19 rsync -a --exclude-from=/run/media/bruno/Multimedia/Videos/.no-backup "/run/media/bruno/Multimedia/Videos" "$HDPath/$YEAR/" || echo ""
|
||||
|
||||
echo -e "\e[97m`date +%r` - Copying Virtual Machines folder (7/7)...\e[39m"
|
||||
myrsync "/run/media/bruno/Multimedia/Virtual Machines" "$HDPath/$YEAR/" || echo ""
|
||||
nice -n 19 rsync -a "/run/media/bruno/Multimedia/Virtual Machines" "$HDPath/$YEAR/" || echo ""
|
||||
|
||||
|
||||
# Show result
|
||||
echo -e "\e[97m`date +%r` - Backup finished. Please, verify your log files.\e[39m"
|
||||
|
||||
echo "$ActiveDisk" > .lastDisk
|
||||
device=$(mount | grep "Backup_$ActiveDisk" | cut -d " " -f1)
|
||||
|
||||
kdialog --title "Backup Complete" --msgbox "Backup finished successfully"
|
||||
echo
|
||||
|
Loading…
Reference in New Issue
Block a user