From 15bb71d784bcabcf1e66e59101bd90ed7c12961f Mon Sep 17 00:00:00 2001 From: sem Date: Wed, 4 Feb 2026 21:28:02 +0100 Subject: [PATCH] Update start script to check continuously --- start-backup.sh | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/start-backup.sh b/start-backup.sh index 0228f5c..2f9ead7 100755 --- a/start-backup.sh +++ b/start-backup.sh @@ -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" \ No newline at end of file +echo "backups VM is online! Continuing with backup"