summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Chudnick <sam@chudnick.com>2021-12-07 20:13:22 -0500
committerSam Chudnick <sam@chudnick.com>2021-12-07 20:13:22 -0500
commitbe06067cd71678e65dafc03ad2ee4710d19458f9 (patch)
treea39ad9a5238bca05eeef9ecf74f4a11f88c010bf
parent4888778f4fa492aef107880bfd53cb1fe774090b (diff)
Fixed issue caused by static path to archive location by replacing onsite with location variable. Added monitoring of return codes from archives for warnings and errors. Added notifications on start and finish. Notify user with different messages based on return codes.
-rwxr-xr-x.local/bin/backups/assimilate36
1 files changed, 32 insertions, 4 deletions
diff --git a/.local/bin/backups/assimilate b/.local/bin/backups/assimilate
index ba31baa..dea18d3 100755
--- a/.local/bin/backups/assimilate
+++ b/.local/bin/backups/assimilate
@@ -19,6 +19,19 @@ LOG="$HOME/.config/borg/log"
19# by the same means. This allows custom password store locations to work with this script. 19# by the same means. This allows custom password store locations to work with this script.
20export BORG_PASSCOMMAND="sudo $SUDO_OPTS -u $USER pass Borg-Backup/$(hostname)-$LOCATION" 20export BORG_PASSCOMMAND="sudo $SUDO_OPTS -u $USER pass Borg-Backup/$(hostname)-$LOCATION"
21 21
22# Create variables and function to monitor exit status
23WARNING=0
24ERROR=0
25check_rc() {
26 rc=$1
27 [ $1 -eq 1 ] && WARNING=1
28 [ $1 -eq 2 ] && ERROR=1
29}
30
31# Start backup
32echo -e "\n$LOCATION $(date)\n" >> $LOG
33notify-send "beginning $LOCATION backup"
34
22# Backup root partition 35# Backup root partition
23sudo $SUDO_OPTS borg create $CREATE_OPTS \ 36sudo $SUDO_OPTS borg create $CREATE_OPTS \
24 --exclude '/dev/*' \ 37 --exclude '/dev/*' \
@@ -27,16 +40,31 @@ sudo $SUDO_OPTS borg create $CREATE_OPTS \
27 --exclude '/tmp/*' \ 40 --exclude '/tmp/*' \
28 --exclude '/mnt/*' \ 41 --exclude '/mnt/*' \
29 --exclude '/media/*' \ 42 --exclude '/media/*' \
30 "/mnt/onsite-backup/$(hostname)::root-{now:%Y-%m-%d}" / 2>>$LOG 43 "/mnt/$LOCATION-backup/$(hostname)::root-{now:%Y-%m-%d}" / 2>>$LOG
44check_rc $?
31 45
32# Backup boot parition 46# Backup boot parition
33sudo $SUDO_OPTS borg create $CREATE_OPTS \ 47sudo $SUDO_OPTS borg create $CREATE_OPTS \
34 "/mnt/onsite-backup/$(hostname)::boot-{now:%Y-%m-%d}" /boot 2>>$LOG 48 "/mnt/$LOCATION-backup/$(hostname)::boot-{now:%Y-%m-%d}" /boot 2>>$LOG
49check_rc $?
35 50
36# Backup home partition 51# Backup home partition
37sudo $SUDO_OPTS borg create $CREATE_OPTS \ 52sudo $SUDO_OPTS borg create $CREATE_OPTS \
38 "/mnt/onsite-backup/$(hostname)::home-{now:%Y-%m-%d}" /home 2>>$LOG 53 "/mnt/$LOCATION-backup/$(hostname)::home-{now:%Y-%m-%d}" /home 2>>$LOG
54check_rc $?
39 55
40# Backup var partition 56# Backup var partition
41sudo $SUDO_OPTS borg create $CREATE_OPTS \ 57sudo $SUDO_OPTS borg create $CREATE_OPTS \
42 "/mnt/onsite-backup/$(hostname)::var-{now:%Y-%m-%d}" /var 2>>$LOG 58 "/mnt/$LOCATION-backup/$(hostname)::var-{now:%Y-%m-%d}" /var 2>>$LOG
59check_rc $?
60
61# Send notifications based on return codes of archives
62
63[ $WARNING -eq 1 ] && notify-send "One or more archives produced a warning" \
64 "Please check the log at $LOG"
65
66[ $ERROR -eq 1 ] && notify-send -u critical \
67 "One or more archives produced an error and was unable to complete" \
68 "Please check the log at $LOG"
69
70[ $WARNING -eq 0 -a $ERROR -eq 0 ] && notify-send "$LOCATION backup complete"