This commit is contained in:
albert 2024-04-04 12:20:46 +09:00
parent 59c9b6b0dc
commit 5faba3b6fc
No known key found for this signature in database
GPG key ID: 64F6C4EB46C4543A

View file

@ -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`"