Hi friends. Long story short, my dad runs Ubuntu, has an exteal hard drive, and I'm trying to set up a crazy simple bash script that I can tie in to a custom desktop file with its own icon. This would allow him to plug in his drive, run the backup "utility", and simply rsync the data to the backup drive. I've gotten everything accomplished, though there's one piece I want to figure out yet. I want there to be a notification in the event an rsync error occurs. Here's the current script.
Code:
#!/bin/bash
if grep -qs '/media/jason/Backup' /etc/mtab; then
notify-send "Backup Started"
rsync -a --progress --delete /home/jason/Desktop/Test /media/jason/Backup/
notify-send "Backup Complete. Please eject the backup drive."
else
notify-send "Backup drive not found. Please plug in the backup drive and restart the backup application.";
exit
fi
I assume I want to tie in another if statement. Something like if rsync error code is 0, proceed to notify-send "Backup Complete" etc etc, else rsync error code (anything but 0) then "notify-send "Error Backing Up""
I'm kind of drawing a blank on how exactly I'd tie that in. Anybody have any suggestions?
برچسب:
نویسنده: استخدام کار