update backups-rpi4

This commit is contained in:
albert 2024-09-16 05:34:32 +02:00
parent a6e5d44f54
commit 4e023d44cf
Signed by: albert
GPG key ID: 3895DD267CA11BA9
2 changed files with 8 additions and 8 deletions

View file

@ -2,7 +2,7 @@ BACKUP_NAME="rsync-media"
GOTIFY_TOKEN=`cat /var/run/secrets/gotify_token | head -n 1`
echo "Sending start message"
payload="{\"message\": \"$BACKUP_NAME Backup has started\nDate: `date`\", \"priority\": 2,\"title\": \"japan-rpi4: $BACKUP_NAME Backup Started\"}"
payload="{\"message\": \"$BACKUP_NAME Backup has started\nDate: `date`\", \"priority\": 2,\"title\": \"backups-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"
driveb=`lsblk -o NAME,SERIAL | grep -v luks | grep 9RGHYP8C | awk {'print $1'}`
@ -21,7 +21,7 @@ echo "Drive 3: $drivec / $mount3 / $mountedc"
# If any drive isn't found, exit:
if [[ $mounteda != 0 ]] || [[ $mountedb != 0 ]] || [[ $mountedc != 0 ]] ; then
echo "One or more drives is not mounted. Exiting"
payload="{\"message\": \"$BACKUP_NAME Backup stopped. One or more local drives are not mounted.\nDate: `date`\", \"priority\": 2,\"title\": \"japan-rpi4: $BACKUP_NAME Backup Stopped\"}"
payload="{\"message\": \"$BACKUP_NAME Backup stopped. One or more local drives are not mounted.\nDate: `date`\", \"priority\": 2,\"title\": \"backups-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
@ -35,16 +35,16 @@ if [[ $count -ge 4 ]] ; then
ps aux | grep $BACKUP_NAME | grep -v grep
ps aux | grep $BACKUP_NAME | grep -v grep | wc -l
payload="{\"message\": \"$BACKUP_NAME stopped. $BACKUP_NAME is still running.\n $count \n.\nDate: `date`\", \"priority\": 2,\"title\": \"japan-rpi4: $BACKUP_NAME Backup Stopped\"}"
payload="{\"message\": \"$BACKUP_NAME stopped. $BACKUP_NAME is still running.\n $count \n.\nDate: `date`\", \"priority\": 2,\"title\": \"backups-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
# Check if the Synology is mounted
check=$(ssh root@nuc-docker01 df -h | grep synology.servers.hs.net | wc -l)
check=$(ssh root@nuc-docker01 df -h | grep \/volume1\/Storage | wc -l)
if [[ $check != 1 ]] ; then
echo "Synology is not mounted on nuc-docker01: check returned $check"
payload="{\"message\": \"Backup stopped. Synology isn't mounted\nDate: `date`\", \"priority\": 2,\"title\": \"japan-rpi4: $BACKUP_NAME Backup Stopped\"}"
payload="{\"message\": \"Backup stopped. Synology isn't mounted\nDate: `date`\", \"priority\": 2,\"title\": \"backups-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
@ -103,5 +103,5 @@ rsync -avr --delete root@nuc-docker01:/Storage/Media/YouTube/ /mnt/$drivec/YouTu
echo -e "======= Time complete: `date`"
echo "Sending completion message"
payload="{\"message\": \"$BACKUP_NAME Backup completed\nDate: `date`\n`df -h | grep sda`\n`df -h | grep sdb`\n`df -h | grep sdc`\", \"priority\": 2,\"title\": \"japan-rpi4: $BACKUP_NAME Backup Complete\"}"
payload="{\"message\": \"$BACKUP_NAME Backup completed\nDate: `date`\n`df -h | grep sda`\n`df -h | grep sdb`\n`df -h | grep sdc`\", \"priority\": 2,\"title\": \"backups-rpi4: $BACKUP_NAME 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"

View file

@ -43,8 +43,8 @@ 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/$drivea/Data/Docker/sysctl.io/"
rsync -avr --delete --exclude=Downloads/ root@framework-server:/Storage/Data/Docker/sysctl.io/ /mnt/$drivea/Data/Docker/sysctl.io/
echo -e "rsync -avr --delete --exclude=Downloads/ root@warsaw-ovh-01:/Storage/Data/Docker/sysctl.io/ /mnt/$drivea/Data/Docker/sysctl.io/"
rsync -avr --delete --exclude=Downloads/ root@warsaw-ovh-01:/Storage/Data/Docker/sysctl.io/ /mnt/$drivea/Data/Docker/sysctl.io/
echo -e "======= Time complete: `date`"
echo "Sending completion message"