Testing sysctl.io backups directly to backups-rpi4

This commit is contained in:
iFargle 2023-12-30 22:11:44 +09:00
parent 6e9bf99d26
commit 7cdedc8abe
4 changed files with 66 additions and 12 deletions

View file

@ -16,31 +16,22 @@
authorizedKeys = [ authorizedKeys = [
# albert@nixos-framework # albert@nixos-framework
''ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAEAQDI7fJtiVPMYN2xJVdr84r1Vrquvo0abJQKtt1NO/F0umyCRvGBaim33KrgyWi8fFCqV6/26JNXx8TdJ6ekczuolxE6/LGIngJ4KUFrAaU9QDdcC7dkDGGUbsGXBNKcvy1uI2dJPqEA1+VotjwTs00Xa6nl9d5VH3yMo2Qgn3HoZvZKbBj2H+06ZJaFckLp7GT7OoPWOE50VxgH8tUsQOlgt/ZaFx7klI7EJLus7lo8gLsQeZPJVT9DXFDUJwwbUeUA/BwnRVPMTF1YrhKat/mvl7iApjNYojxClcEArj2e/hqV7EQrDv8wuW7ocb1HW/r2RLtytP27wJNc9RkrFL4mhvsRbFX2XmhbCoyCS4a1fZyxBqSS7jPbG8IBiAaMi9R45b1Jg4zE+960BKKpcrKJoU5+JHX23XJM4+1Mz9aCL2elSed5KeQDjCGdiYRL7NaqXzVK1qjgPbNsdEoL2VYuz8lT1yAtAEh7O+zFf/Argj5qaTlcRfSvKSYT3/rIj75MBLu3XKrcxBAl+2GE0WW8Wsk04XPiyR3dvAhpbLlkpQFCzsJvkAAwJr6Nh3ihY9bwBgLX8zY8ry+gkSMEsa5coazINkvJLtlLWOGt3Z5wkRIWXIrWDpGyLQCOKgUekUVIvYqJDYYuYMk/DJUJQ2OOtZMSHjXd/ajAGfRRU6hQoYopJIAPVBsZNAmQkVz1ijqX9L/B3LkPUTB3q4rxveTFFxdwFIv/QZp3Q258Sl/zfki1QPH+11Eezr2mmMLMc/AzPBONRb3T7/fv8aLXWBoI20az0lb+xCJFBkH4iVKWxAdpBD2Ou/Bc8QiEtPD5g59/bVkWnLcx03TrSL1UChcV7BIlBO0/CE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ert@nixos-vm-01''
# (Thu Dec 28 19:30:06 JST 2023) albert@framework-server # (Thu Dec 28 19:30:06 JST 2023) albert@framework-server
''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAODamRCvyVOGmMSMXWdUzjcM2GsApizCvXEWKHiKhGk albert@framework-server'' ''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAODamRCvyVOGmMSMXWdUzjcM2GsApizCvXEWKHiKhGk albert@framework-server''
# (Thu Dec 28 19:34:47 JST 2023) albert@osaka-linode-01 # (Thu Dec 28 19:34:47 JST 2023) albert@osaka-linode-01
''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEsl8Z0jXAboCBdAtWDkssHI3M3lHSPaM4uUgxzBJI41 albert@osaka-linode-01'' ''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEsl8Z0jXAboCBdAtWDkssHI3M3lHSPaM4uUgxzBJI41 albert@osaka-linode-01''
# (Fri Dec 15 09:34:02 AM UTC 2023) forgejo-runner # (Fri Dec 15 09:34:02 AM UTC 2023) forgejo-runner
''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJJE7z4JlohTe2TfB5ovsDWMT+M+V9AyQ6dXNelX6oGU forgejo-runner'' ''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJJE7z4JlohTe2TfB5ovsDWMT+M+V9AyQ6dXNelX6oGU forgejo-runner''
# (Fri Dec 15 09:34:02 AM UTC 2023) albert@piaware-rpi4 # (Fri Dec 15 09:34:02 AM UTC 2023) albert@piaware-rpi4
''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINR8PCfKOTArLemqmnHom4vWJ6u8wrlpG6/gSqeYo/qD albert@piaware-rpi4'' ''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINR8PCfKOTArLemqmnHom4vWJ6u8wrlpG6/gSqeYo/qD albert@piaware-rpi4''
# (Fri Dec 15 11:40:53 AM UTC 2023) albert@backups-rpi4 # (Fri Dec 15 11:40:53 AM UTC 2023) albert@backups-rpi4
''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGNkKoS32K487JaFza9TUFwrjwe9P7SNIHbVNxhzmRcI albert@backups-rpi4'' ''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGNkKoS32K487JaFza9TUFwrjwe9P7SNIHbVNxhzmRcI albert@backups-rpi4''
# (Tue Dec 26 10:33:58 AM UTC 2023) abc@rdesktop # (Tue Dec 26 10:33:58 AM UTC 2023) abc@rdesktop
''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKa86iTPkRDwga4/T3XdyWfu5xH8oL/AWWWozz3rUyuA abc@rdesktop'' ''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKa86iTPkRDwga4/T3XdyWfu5xH8oL/AWWWozz3rUyuA abc@rdesktop''
# (Thu Dec 28 10:56:22 AM UTC 2023) pixel-5 # (Thu Dec 28 10:56:22 AM UTC 2023) pixel-5
''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP7HMCutPvexUsbjAzpd0ZOsmVtg80MOaGnCOv+I3UBf pixel-5'' ''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP7HMCutPvexUsbjAzpd0ZOsmVtg80MOaGnCOv+I3UBf pixel-5''
# (Thu Dec 28 19:23:15 JST 2023) Win10 Desktop # (Thu Dec 28 19:23:15 JST 2023) Win10 Desktop
''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMnAgxirNxrWnYARBG4sQ9wp21zK9uhrcNpFzegTk3Kl albert j. copeland@win10-desktop'' ''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMnAgxirNxrWnYARBG4sQ9wp21zK9uhrcNpFzegTk3Kl albert j. copeland@win10-desktop''
]; ];

View file

@ -185,8 +185,8 @@ fi
echo -e "================================================================================" echo -e "================================================================================"
echo -e "======= Time: `date`" echo -e "======= Time: `date`"
echo -e "rsync -avr --delete --exclude=Downloads/ root@nuc-docker01:/Storage/Data/ /mnt/$drive1/Data/" echo -e "rsync -avr --delete --exclude=Downloads/ --exclude=Data/Docker/sysctl\.io/ root@nuc-docker01:/Storage/Data/ /mnt/$drive1/Data/"
rsync -avr --delete --exclude=Downloads/ root@nuc-docker01:/Storage/Data/ /mnt/$drive1/Data/ rsync -avr --delete --exclude=Downloads/ --exclude=Data/Docker/sysctl\.io/ root@nuc-docker01:/Storage/Data/ /mnt/$drive1/Data/
echo -e "======= Time: `date`" echo -e "======= Time: `date`"
echo -e "======= Time complete: `date`" echo -e "======= Time complete: `date`"
@ -195,12 +195,71 @@ echo "Sending completion message"
payload="{\"message\": \"Data Vol Backup completed\nDate: `date`\n`df -h | grep sda`\n`df -h | grep sdb`\n`df -h | grep sdc`\", \"priority\": 2,\"title\": \"backups-rpi4: Data Vol Backup Complete\"}" payload="{\"message\": \"Data Vol Backup completed\nDate: `date`\n`df -h | grep sda`\n`df -h | grep sdb`\n`df -h | grep sdc`\", \"priority\": 2,\"title\": \"backups-rpi4: Data Vol Backup Complete\"}"
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" 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"
'';
rsync-sysctl = pkgs.writeScriptBin "rsync-sysctl" ''
#!${pkgs.stdenv.shell}
# Send the gotify notification:
GOTIFY_TOKEN=`cat /var/run/secrets/gotify_token | head -n 1`
payload="{\"message\": \"sysctl.io Backup has started\nDate: `date`\", \"priority\": 2,\"title\": \"backups-rpi4: sysctl.io 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"
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`
mounted1=`echo $?`
mount2=`mount -l | grep $drive2`
mounted2=`echo $?`
mount3=`mount -l | grep $drive3`
mounted3=`echo $?`
echo "status"
echo "$drive1 / $mount1 / $mounted1"
echo "$drive2 / $mount2 / $mounted2"
echo "$drive3 / $mount3 / $mounted3"
# If any drive isn't found, exit:
if [[ $mounted1 != 0 ]] && [[ munted2 != 0 ]] && [[ $mounted3 != 0 ]] ; then
payload="{\"message\": \"sysctl.io Backup stopped. One or more local drives are not mounted.\nDate: `date`\", \"priority\": 2,\"title\": \"backups-rpi4: sysctl.io 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"
fi
echo "Drive 1: $drive1"
echo "Drive 2: $drive2"
echo "Drive 3: $drive3"
echo -e "======= Time started : `date`"
if [[ `ps aux | grep rsync | grep -v grep | grep -v rsync-sysctl` ]] ; then
echo -e "================================================================================"
echo -e "rsync still running. Exiting...."
echo -e "======= Time complete: `date`"
exit
fi
echo -e "================================================================================"
echo -e "======= Time: `date`"
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`"
echo "Sending completion message"
payload="{\"message\": \"sysctl.io Backup completed\nDate: `date`\n`df -h | grep sda`\n`df -h | grep sdb`\n`df -h | grep sdc`\", \"priority\": 2,\"title\": \"backups-rpi4: sysctl.io Backup Complete\"}"
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"
''; '';
in in
{ {
environment.systemPackages = [ environment.systemPackages = [
rsync-backups rsync-backups
rsync-data-vol rsync-data-vol
rsync-sysctl
]; ];
# Set up the secret for the password: # Set up the secret for the password:

View file

@ -6,6 +6,7 @@
# https://git.sysctl.io/albert/random-scripts/src/branch/master/rsync-pi/rsync-all.sh # https://git.sysctl.io/albert/random-scripts/src/branch/master/rsync-pi/rsync-all.sh
''0 9 * * * root rsync-backups >> /root/logs/backups/rsync_`date "+\%Y-\%m-\%d"`.log'' ''0 9 * * * root rsync-backups >> /root/logs/backups/rsync_`date "+\%Y-\%m-\%d"`.log''
''0 19 * * 3 root rsync-data-vol >> /root/logs/data-vol/rsync_`date "+\%Y-\%m-\%d"`.log'' ''0 19 * * 3 root rsync-data-vol >> /root/logs/data-vol/rsync_`date "+\%Y-\%m-\%d"`.log''
''0 1 * * * root rsync-sysctl >> /root/logs/sysctl/rsync_`date "+\%Y-\%m-\%d"`.log''
]; ];
}; };
} }

View file

@ -20,6 +20,9 @@
pkgs.distrobox pkgs.distrobox
]; ];
# backups-rpi4 cron job to back up sysctl.io's Docker files
users.users.root.openssh.authorizedKeys.keys = [ ''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKp2wgqFcr0LGaUXbom88/zK2631pysePUWIaCMljT0K root@backups-rpi4'' ];
# steam , etc # steam , etc
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;