#!/bin/bash DIALOG=Xdialog BACKUP_SCRIPT=backup_script BACKUP_TIME="2pm" BACKUP_DAYS=1 SNOOZE_MINS=5 $DIALOG --display=:0.0 --wrap --title "Backup Reminder" \ --ok-label Continue \ --cancel-label Snooze \ --yesno "You need to do a backup now. Please attach \ your external backup drive and click 'Continue' to continue \ with the backup or 'Snooze' to postpone the backup for a few \ minutes or close the window to skip this scheduled backup \ and reschedule the backup for next time." 15 60 &> /dev/null return_value=$? # if the command succeeded (the user clicked continue) # proceed with the backup if [ $return_value = 0 ]; then $BACKUP_SCRIPT success=$? # if the backup script succeeded then send mail to # the user and schedule the next backup if [ $success = 0 ]; then echo "backup succeeded. scheduling next backup for" echo $0 | at $BACKUP_TIME + $BACKUP_DAYS days # the backup script failed so stop the backup loop # and mail the user the failed message else echo "backup failed! stopping backup loop! please check your backup script and re-run this script!" fi # the backup has been skipped (user closed the window) # so reschedule the backup for the next scheduled time elif [ $return_value = 255 ]; then echo "backup skipped. scheduling next backup for" echo $0 | at $BACKUP_TIME + $BACKUP_DAYS days # either the dialog command failed because X wasn't available # or the user snoozed the backup, so reschedule the backup else echo $0 | at now + $SNOOZE_MINS minutes &> /dev/null fi