diff options
Diffstat (limited to 'arch-system/borgbackup')
-rwxr-xr-x | arch-system/borgbackup | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/arch-system/borgbackup b/arch-system/borgbackup index 5d6c8b4..66d1a36 100755 --- a/arch-system/borgbackup +++ b/arch-system/borgbackup @@ -16,10 +16,14 @@ cleanup() { sudo -n /usr/bin/backup-sudo cleanup } -handle_failure() { +notify_user() { if ! [ -t 1 ]; then - notify-send -u critical "Backup failed!" + notify-send "$@" fi +} + +handle_failure() { + notify_user -u critical "Backup failed!" echo "Backup failed!" >&2 cleanup @@ -46,7 +50,13 @@ backup() { borg create --stats $borg_progress \ --exclude-from ~/.borg_exclude \ --show-rc \ - ::"$(basename "$1")" . + ::"$(basename "$1")" . && rc=$? || rc=$? + if [ $rc -eq 1 ]; then + # borg defines return code 1 as warning, usually permission stuff + notify_user "Warning: borgbackup returned 1. Check logs" + elif [ $rc -gt 1 ]; then + handle_failure + fi cleanup sudo -n backup-sudo delete_snapshot "$1" @@ -59,9 +69,7 @@ fi if ! ssh -To BatchMode=yes -o ConnectTimeout=$NETWORK_TIMEOUT \ -o IdentitiesOnly=yes -o ConnectionAttempts=20 -i ~/.ssh/borg_key \ "$BORG_HOST" "borg --version" > /dev/null; then - if ! [ -t 1 ]; then - notify-send "Backups: upload skipped" - fi + notify_user "Backup: upload skipped" echo "SSH server not reachable, skipping upload" >&2 exit 0 fi |