UPdate script

This commit is contained in:
albert 2024-05-01 22:17:34 +09:00
parent 0168dedf91
commit f635b7d3ea
No known key found for this signature in database
GPG key ID: 64F6C4EB46C4543A

View file

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