diff --git a/nixos/hosts/backups-rpi4/backup-script.nix b/nixos/hosts/backups-rpi4/backup-script.nix index 61b92d21..5cc73171 100644 --- a/nixos/hosts/backups-rpi4/backup-script.nix +++ b/nixos/hosts/backups-rpi4/backup-script.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ config, lib, pkgs, ... }: let rsync-backups = pkgs.writeScriptBin "rsync-backups" '' #!${pkgs.stdenv.shell} @@ -25,10 +25,10 @@ echo "$drive2 / $mount2 / $mounted2" echo "$drive3 / $mount3 / $mounted3" # If any drive isn't found, exit: -if [[ $mounted1 != 0 ]] || [[ $mounted2 != 0 ]] || [[ $mounted3 != 0 ]] ; then +if [[ $mounted1 != 0 ]] || [[ mounted2 != 0 ]] && [[ $mounted3 != 0 ]] ; then payload="{\"message\": \"Backup stopped. One or more local drives are not mounted.\nDate: `date`\", \"priority\": 2,\"title\": \"backups-rpi4: Backup Stopped\"}" curl -X "POST" "https://gotify.sysctl.io/message" -H "accept: application/json" -H "Content-Type: application/json" -H "X-Gotify-Key: $GOTIFY_TOKEN" -d "$payload" - exit + fi echo "Drive 1: $drive1" @@ -208,6 +208,7 @@ drive1=`lsblk -o NAME,SERIAL | grep -v luks | grep 9RGHYP8C | awk {'print $1'}` drive2=`lsblk -o NAME,SERIAL | grep -v luks | grep 9RGXW93C | awk {'print $1'}` drive3=`lsblk -o NAME,SERIAL | grep -v luks | grep 5QH05G3F | awk {'print $1'}` +mount1=`mount -l | grep $drive1` mount1=`mount -l | grep $drive1` mounted1=`echo $?` mount2=`mount -l | grep $drive2` @@ -242,8 +243,8 @@ fi echo -e "================================================================================" echo -e "======= Time: `date`" -echo -e "rsync -avr --delete root@framework-server:/Storage/Data/Docker/sysctl.io/ /mnt/$drive1/Data/Docker/sysctl.io/" -rsync -avr --delete root@framework-server:/Storage/Data/Docker/sysctl.io/ /mnt/$drive1/Data/Docker/sysctl.io/ +echo -e "rsync -avr --delete --exclude=Downloads/ root@framework-server:/Storage/Data/Docker/sysctl.io/ /mnt/$drive1/Data/Docker/sysctl.io/" +rsync -avr --delete --exclude=Downloads/ root@framework-server:/Storage/Data/Docker/sysctl.io/ /mnt/$drive1/Data/Docker/sysctl.io/ echo -e "======= Time: `date`" echo -e "======= Time complete: `date`"