From f635b7d3ea5f256d75859594c517ccf240772971 Mon Sep 17 00:00:00 2001 From: albert Date: Wed, 1 May 2024 22:17:34 +0900 Subject: [PATCH] UPdate script --- .../backups-rpi4/scripts/rsync-sysctl.sh | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/nixos/hosts/backups-rpi4/scripts/rsync-sysctl.sh b/nixos/hosts/backups-rpi4/scripts/rsync-sysctl.sh index d0bca87a..48552d88 100644 --- a/nixos/hosts/backups-rpi4/scripts/rsync-sysctl.sh +++ b/nixos/hosts/backups-rpi4/scripts/rsync-sysctl.sh @@ -5,6 +5,16 @@ echo "Sending start message" payload="{\"message\": \"$BACKUP_NAME Backup has started\nDate: `date`\", \"priority\": 2,\"title\": \"japan-rpi4: $BACKUP_NAME Backup Started\"}" 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" +# If an old backup is still running, don't continue +if [[ `ps aux | grep $BACKUP_NAME | grep -v grep` ]] ; then + echo -e "$BACKUP_NAME rsync still running. Exiting...." + echo "Output: " + ps aux | grep $BACKUP_NAME | grep -v grep + payload="{\"message\": \"$BACKUP_NAME stopped. $BACKUP_NAME is still running.\nDate: `date`\", \"priority\": 2,\"title\": \"japan-rpi4: $BACKUP_NAME 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 + 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'}` @@ -26,16 +36,6 @@ if [[ $mounted1 != 0 ]] || [[ $mounted2 != 0 ]] || [[ $mounted3 != 0 ]] ; then exit fi -# If an old backup is still running, don't continue -if [[ `ps aux | grep $BACKUP_NAME | grep -v grep` ]] ; then - echo -e "$BACKUP_NAME rsync still running. Exiting...." - echo "Output: " - ps aux | grep $BACKUP_NAME | grep -v grep - payload="{\"message\": \"$BACKUP_NAME stopped. $BACKUP_NAME is still running.\nDate: `date`\", \"priority\": 2,\"title\": \"japan-rpi4: $BACKUP_NAME 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 - # Start the backups echo -e "======= Time started : `date`" echo -e "rsync -avr --delete --exclude=Downloads/ root@framework-server:/Storage/Data/Docker/sysctl.io/ /mnt/$drive1/Data/Docker/sysctl.io/"