From f8d0558b2834d6d2624916871900978431ad2ef4 Mon Sep 17 00:00:00 2001 From: albert Date: Sun, 3 Mar 2024 11:12:08 +0900 Subject: [PATCH] update backup scripts --- nixos/hosts/backups-rpi4/backup-script.nix | 50 +++++++++++----------- nixos/hosts/nuc-server/cron.nix | 2 +- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/nixos/hosts/backups-rpi4/backup-script.nix b/nixos/hosts/backups-rpi4/backup-script.nix index ab45d921..ec5f4fae 100644 --- a/nixos/hosts/backups-rpi4/backup-script.nix +++ b/nixos/hosts/backups-rpi4/backup-script.nix @@ -37,9 +37,9 @@ echo "Drive 2: $drive2" echo "Drive 3: $drive3" echo "Checking if the NAS is mounted on nuc-docker01:" -check=$(ssh root@nuc-docker01 df -h | grep Storage | wc -l) -if [[ $check != 3 ]] ; then - payload="{\"message\": \"Backup stopped. nuc-docker01 does not have 3 mounts in Storage\nDate: `date`\", \"priority\": 2,\"title\": \"backups-rpi4: Backup Stopped\"}" +check=$(ssh root@nuc-docker01 df -h | grep 192.168.1.100) +if [[ $check != 1 ]] ; then + payload="{\"message\": \"Backup stopped. Synology isn't 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 @@ -73,18 +73,18 @@ rsync -avr --delete root@nuc-docker01:/Storage/Backups/Docker/ /mnt/$drive1/Back echo -e "================================================================================" echo -e "======= Time: `date`" -echo -e "rsync -avr --delete root@nuc-docker01:/Storage/Video/Pictures/ /mnt/$drive1/Pictures/" -rsync -avr --delete root@nuc-docker01:/Storage/Video/Pictures/ /mnt/$drive1/Pictures/ +echo -e "rsync -avr --delete root@nuc-docker01:/Storage/Media/Pictures/ /mnt/$drive1/Pictures/" +rsync -avr --delete root@nuc-docker01:/Storage/Media/Pictures/ /mnt/$drive1/Pictures/ echo -e "================================================================================" echo -e "======= Time: `date`" -echo -e "rsync -avr --delete root@nuc-docker01:/Storage/Video/Books/ /mnt/$drive1/Books/" -rsync -avr --delete root@nuc-docker01:/Storage/Video/Books/ /mnt/$drive1/Books/ +echo -e "rsync -avr --delete root@nuc-docker01:/Storage/Media/Books/ /mnt/$drive1/Books/" +rsync -avr --delete root@nuc-docker01:/Storage/Media/Books/ /mnt/$drive1/Books/ echo -e "================================================================================" echo -e "======= Time: `date`" -echo -e "rsync -avr --delete root@nuc-docker01:/Storage/Video/Music/ /mnt/$drive1/Music/" -rsync -avr --delete root@nuc-docker01:/Storage/Video/Music/ /mnt/$drive1/Music/ +echo -e "rsync -avr --delete root@nuc-docker01:/Storage/Media/Music/ /mnt/$drive1/Music/" +rsync -avr --delete root@nuc-docker01:/Storage/Media/Music/ /mnt/$drive1/Music/ # echo -e "================================================================================" # echo -e "======= Time: `date`" @@ -93,33 +93,33 @@ rsync -avr --delete root@nuc-docker01:/Storage/Video/Music/ /mnt/$drive1/Music/ echo -e "================================================================================" echo -e "======= Time: `date`" -echo -e "rsync -avr --delete root@nuc-docker01:/Storage/Video/Movies/ /mnt/$drive2/Movies/" -rsync -avr --delete root@nuc-docker01:/Storage/Video/Movies/ /mnt/$drive2/Movies/ +echo -e "rsync -avr --delete root@nuc-docker01:/Storage/Media/Movies/ /mnt/$drive2/Movies/" +rsync -avr --delete root@nuc-docker01:/Storage/Media/Movies/ /mnt/$drive2/Movies/ echo -e "================================================================================" echo -e "======= Time: `date`" -echo -e "rsync -avr --delete root@nuc-docker01:/Storage/Video/TV_Shows/[0-9]* /mnt/$drive1/TV_Shows/" -rsync -avr --delete root@nuc-docker01:/Storage/Video/TV_Shows/[0-9]* /mnt/$drive1/TV_Shows/ +echo -e "rsync -avr --delete root@nuc-docker01:/Storage/Media/TV_Shows/[0-9]* /mnt/$drive1/TV_Shows/" +rsync -avr --delete root@nuc-docker01:/Storage/Media/TV_Shows/[0-9]* /mnt/$drive1/TV_Shows/ echo -e "================================================================================" echo -e "======= Time: `date`" -echo -e "rsync -avr --delete root@nuc-docker01:/Storage/Video/TV_Shows/[A-K]* /mnt/$drive1/TV_Shows/" -rsync -avr --delete root@nuc-docker01:/Storage/Video/TV_Shows/[A-E]* /mnt/$drive1/TV_Shows/ +echo -e "rsync -avr --delete root@nuc-docker01:/Storage/Media/TV_Shows/[A-K]* /mnt/$drive1/TV_Shows/" +rsync -avr --delete root@nuc-docker01:/Storage/Media/TV_Shows/[A-E]* /mnt/$drive1/TV_Shows/ echo -e "================================================================================" echo -e "======= Time: `date`" -echo -e "rsync -avr --delete root@nuc-docker01:/Storage/Video/TV_Shows/[L-R]* /mnt/$drive2/TV_Shows/" -rsync -avr --delete root@nuc-docker01:/Storage/Video/TV_Shows/[F-R]* /mnt/$drive2/TV_Shows/ +echo -e "rsync -avr --delete root@nuc-docker01:/Storage/Media/TV_Shows/[L-R]* /mnt/$drive2/TV_Shows/" +rsync -avr --delete root@nuc-docker01:/Storage/Media/TV_Shows/[F-R]* /mnt/$drive2/TV_Shows/ echo -e "================================================================================" echo -e "======= Time: `date`" -echo -e "rsync -avr --delete root@nuc-docker01:/Storage/Video/TV_Shows/[S-Z]* /mnt/$drive3/TV_Shows/" -rsync -avr --delete root@nuc-docker01:/Storage/Video/TV_Shows/[S-Z]* /mnt/$drive3/TV_Shows/ +echo -e "rsync -avr --delete root@nuc-docker01:/Storage/Media/TV_Shows/[S-Z]* /mnt/$drive3/TV_Shows/" +rsync -avr --delete root@nuc-docker01:/Storage/Media/TV_Shows/[S-Z]* /mnt/$drive3/TV_Shows/ echo -e "================================================================================" echo -e "======= Time: `date`" -echo -e "rsync -avr --delete root@nuc-docker01:/Storage/Video/YouTube /mnt/$drive3/YouTube/" -rsync -avr --delete root@nuc-docker01:/Storage/Video/YouTube/ /mnt/$drive3/YouTube/ +echo -e "rsync -avr --delete root@nuc-docker01:/Storage/Media/YouTube /mnt/$drive3/YouTube/" +rsync -avr --delete root@nuc-docker01:/Storage/Media/YouTube/ /mnt/$drive3/YouTube/ echo -e "================================================================================" echo -e "======= Time: `date`" @@ -167,9 +167,9 @@ echo "Drive 2: $drive2" echo "Drive 3: $drive3" echo "Checking if the NAS is mounted on nuc-docker01:" -check=$(ssh root@nuc-docker01 df -h | grep Storage | wc -l) -if [[ $check != 3 ]] ; then - payload="{\"message\": \"Data Vol Backup stopped. nuc-docker01 does not have 3 mounts in Storage\nDate: `date`\", \"priority\": 2,\"title\": \"backups-rpi4: Data Vol Backup Stopped\"}" +check=$(ssh root@nuc-docker01 df -h | grep 192.168.1.100) +if [[ $check != 1 ]] ; then + payload="{\"message\": \"Data Vol Backup stopped. Synology isn't mounted\nDate: `date`\", \"priority\": 2,\"title\": \"backups-rpi4: Data Vol 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 @@ -267,4 +267,4 @@ in owner = "root"; sopsFile = ../../../secrets/hosts/backups-rpi4.yaml; }; -} \ No newline at end of file +} diff --git a/nixos/hosts/nuc-server/cron.nix b/nixos/hosts/nuc-server/cron.nix index 4f879780..9d9bf58d 100644 --- a/nixos/hosts/nuc-server/cron.nix +++ b/nixos/hosts/nuc-server/cron.nix @@ -54,4 +54,4 @@ # # # back up crontab: # 0 0 * * * /usr/bin/crontab -l > /Storage/Data/Temporary/crontab -} \ No newline at end of file +}