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)"
is_online="offline"
if ping -W 1 -c 1 10.10.100.52 > /dev/null 2>&1; then
is_online="online"
fi
VM_IP="10.10.100.52"
MAX_WAIT=180
SLEEP_INTERVAL=5
ELAPSED=0
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 "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
echo "waiting for backups VM to come online..."
is_online_after_cmd=$(ping -W 1 -c 1 10.10.100.52)
if [ "$?" == "1" ]; then
echo "Backups VM is still offline!"
curl "http://10.10.100.12:8123/stopbackup"
while ! ping -W 1 -c 1 "$VM_IP" > /dev/null 2>&1; do
sleep "$SLEEP_INTERVAL"
ELAPSED=$((ELAPSED + SLEEP_INTERVAL))
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
fi
fi
done
echo "backups VM is online! Continuing with backup"