Update start script to check continuously

This commit is contained in:
sem
2026-02-04 21:28:02 +01:00
parent ad9345c0e8
commit 15bb71d784

View File

@@ -2,28 +2,25 @@
echo "starting backup at $(date)" echo "starting backup at $(date)"
is_online="offline" VM_IP="10.10.100.52"
MAX_WAIT=180
if ping -W 1 -c 1 10.10.100.52 > /dev/null 2>&1; then SLEEP_INTERVAL=5
is_online="online" ELAPSED=0
fi
echo "sending start command" echo "sending start command"
curl "http://10.10.100.12:8123/startbackup" curl -s "http://10.10.100.12:8123/startbackup"
if [ "$is_online" = "online" ]; then echo "waiting for backups VM to come online..."
echo "VM already online"
else
echo "backups VM was offline! It's starting up now..."
echo "waiting 30 seconds for the VM to start up..."
sleep 30
fi
is_online_after_cmd=$(ping -W 1 -c 1 10.10.100.52) while ! ping -W 1 -c 1 "$VM_IP" > /dev/null 2>&1; do
if [ "$?" == "1" ]; then sleep "$SLEEP_INTERVAL"
echo "Backups VM is still offline!" ELAPSED=$((ELAPSED + SLEEP_INTERVAL))
curl "http://10.10.100.12:8123/stopbackup"
if [ "$ELAPSED" -ge "$MAX_WAIT" ]; then
echo "Backups VM did not come online within ${MAX_WAIT}s"
curl -s "http://10.10.100.12:8123/stopbackup"
exit 1 exit 1
fi fi
done
echo "backups VM is online! Continuing with backup" echo "backups VM is online! Continuing with backup"