diff --git a/backups/cron/daily.sh b/backups/cron/daily.sh index 79187c4..9431e81 100755 --- a/backups/cron/daily.sh +++ b/backups/cron/daily.sh @@ -1,9 +1,19 @@ -sudo /usr/bin/rsnapshot daily + #!/bin/bash -sudo chown -R thomas:thomas /mnt/backups +USER=thomas +export XDG_RUNTIME_DIR=/run/user/1000 -if [ $? -eq 0 ]; then - /usr/bin/notify-send 'Backup' 'Daily backup completed successfully' + +if mountpoint -q /media/backups; then + sudo /usr/bin/rsnapshot daily + sudo chown -R thomas:thomas /media/backups + # Check the exit status of the rsnapshot command + if [ $? -eq 0 ]; then + /usr/bin/notify-send 'rsync' 'Daily backup completed successfully' + else + /usr/bin/notify-send -u critical 'rsync' 'Daily backup failed' + fi else - /usr/bin/notify-send 'Backup' 'Daily backup failed' + echo "Backup drive not mounted" + /usr/bin/notify-send -u critical 'Backup' 'Error: backup drive not mounted' fi diff --git a/backups/cron/hourly.sh b/backups/cron/hourly.sh index 45b3f35..c920473 100755 --- a/backups/cron/hourly.sh +++ b/backups/cron/hourly.sh @@ -1,9 +1,19 @@ -sudo /usr/bin/rsnapshot hourly +#!/bin/bash -sudo chown -R thomas:thomas /mnt/backups +USER=thomas +export XDG_RUNTIME_DIR=/run/user/1000 -if [ $? -eq 0 ]; then - /usr/bin/notify-send 'Backup' 'Hourly backup completed successfully' + +if mountpoint -q /media/backups; then + sudo /usr/bin/rsnapshot hourly + sudo chown -R thomas:thomas /media/backups + # Check the exit status of the rsnapshot command + if [ $? -eq 0 ]; then + /usr/bin/notify-send 'rsync' 'Hourly backup completed successfully' + else + /usr/bin/notify-send -u critical 'rsync' 'Hourly backup failed' + fi else - /usr/bin/notify-send 'Backup' 'Hourly backup failed' + echo "Backup drive not mounted" + /usr/bin/notify-send -u critical 'Backup' 'Error: backup drive not mounted' fi diff --git a/backups/cron/monthly.sh b/backups/cron/monthly.sh index 4ea2903..ef01db4 100755 --- a/backups/cron/monthly.sh +++ b/backups/cron/monthly.sh @@ -1,9 +1,19 @@ -sudo /usr/bin/rsnapshot monthly +#!/bin/bash -sudo chown -R thomas:thomas /mnt/backups +USER=thomas +export XDG_RUNTIME_DIR=/run/user/1000 -if [ $? -eq 0 ]; then - /usr/bin/notify-send 'Backup' 'Monthly backup completed successfully' + +if mountpoint -q /media/backups; then + sudo /usr/bin/rsnapshot monthly + sudo chown -R thomas:thomas /media/backups + # Check the exit status of the rsnapshot command + if [ $? -eq 0 ]; then + /usr/bin/notify-send 'rsync' 'Monthly backup completed successfully' + else + /usr/bin/notify-send -u critical 'rsync' 'Monthly backup failed' + fi else - /usr/bin/notify-send 'Backup' 'Monthly backup failed' + echo "Backup drive not mounted" + /usr/bin/notify-send -u critical 'Backup' 'Error: backup drive not mounted' fi diff --git a/backups/cron/weekly.sh b/backups/cron/weekly.sh index f0c512c..07aa885 100755 --- a/backups/cron/weekly.sh +++ b/backups/cron/weekly.sh @@ -1,9 +1,19 @@ -sudo /usr/bin/rsnapshot weekly +#!/bin/bash -sudo chown -R thomas:thomas /mnt/backups +USER=thomas +export XDG_RUNTIME_DIR=/run/user/1000 -if [ $? -eq 0 ]; then - /usr/bin/notify-send 'Backup' 'Weekly backup completed successfully' + +if mountpoint -q /media/backups; then + sudo /usr/bin/rsnapshot weekly + sudo chown -R thomas:thomas /media/backups + # Check the exit status of the rsnapshot command + if [ $? -eq 0 ]; then + /usr/bin/notify-send 'rsync' 'Weekly backup completed successfully' + else + /usr/bin/notify-send -u critical 'rsync' 'Weekly backup failed' + fi else - /usr/bin/notify-send 'Backup' 'Weekly backup failed' + echo "Backup drive not mounted" + /usr/bin/notify-send -u critical 'Backup' 'Error: backup drive not mounted' fi diff --git a/backups/rsnapshot.conf b/backups/rsnapshot.conf index 1691b69..eeedd50 100644 --- a/backups/rsnapshot.conf +++ b/backups/rsnapshot.conf @@ -21,7 +21,7 @@ config_version 1.2 # All snapshots will be stored under this root directory. # -snapshot_root /run/media/thomas/archbish_backups +snapshot_root /media/backups # If no_create_root is enabled, rsnapshot will not automatically create the # snapshot_root directory. This is particularly useful if you are backing # up to removable media, such as a FireWire or USB drive.