I'm trying to create two scripts. One called backup, the other called cancel_backup. When backup is ran, it checks if a directory is available, if so it begins the backup. If not, it tries again every 30 seconds until the directory is found.
If cancel_backup is ran, the backup script should terminate.
Here's my code so far:
#/bin/bash!
backup_location='/media/tom/EXTERNAL/Backups/Areca'
while [ ! -d $backup_location ]
do
if [ ! $CANCEL_BACKUP ]
then
notify-send --icon=/home/tom/icons/dialog-warning.png "Backup Cancelled." "Backup has been cancelled by the user."
exit 0
else
notify-send --icon=/home/tom/icons/dialog-error.png "Backup Directory Inaccessible" "External backup directory is inaccessible. Retrying in 30 seconds."
sleep 30
fi
done
notify-send --icon=/home/tom/icons/dialog-info.png "Beginning Backup" "External backup directory located, beginning backup."
I've attempted to use export, however the variable is still not accessible to any other scripts unless they I use source within the above script.
I need to be able to run the scripts independently, but still update $CANCEL_BACKUP from a different script.
source. Maybe decide based on exit codes of your scripts?