Update script for better error handling
All checks were successful
build-linode-img / build-linode-img (push) Successful in 2m29s
All checks were successful
build-linode-img / build-linode-img (push) Successful in 2m29s
This commit is contained in:
parent
bab7a1cf97
commit
7e7502696a
1 changed files with 22 additions and 3 deletions
|
@ -9,9 +9,28 @@ GOTIFY_TOKEN=`cat /var/run/secrets/gotify_token | head -n 1`
|
||||||
payload="{\"message\": \"Backup has started\nDate: `date`\", \"priority\": 2,\"title\": \"backups-rpi4: Backup Started\"}"
|
payload="{\"message\": \"Backup has started\nDate: `date`\", \"priority\": 2,\"title\": \"backups-rpi4: 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"
|
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 crypt | grep 9RGHYP8C | awk {'print $1'}`
|
drive1=`lsblk -o NAME,SERIAL | grep -v luks | grep 9RGHYP8C | awk {'print $1'}`
|
||||||
drive2=`lsblk -o NAME,SERIAL | grep -v crypt | grep 9RGXW93C | awk {'print $1'}`
|
drive2=`lsblk -o NAME,SERIAL | grep -v luks | grep 9RGXW93C | awk {'print $1'}`
|
||||||
drive3=`lsblk -o NAME,SERIAL | grep -v crypt | grep 5QH05G3F | 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\": \"Backup stopped. One or more local drives are not 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"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Drive 1: $drive1"
|
echo "Drive 1: $drive1"
|
||||||
echo "Drive 2: $drive2"
|
echo "Drive 2: $drive2"
|
||||||
|
|
Loading…
Reference in a new issue