#!/bin/bash if [ -z "$1" ] then echo "Running backup script at $(date)" else echo "Running backup $1 script at $(date)" fi is_online="offline" if ping -W 1 -c 1 10.10.100.52 > /dev/null 2>&1; then is_online="online" fi echo "sending start command" curl "http://10.10.100.12:8123/startbackup" if [ "$is_online" = "online" ]; then echo "VM already online" else echo "backups VM is offline!" 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) if [ "$?" == "1" ]; then echo "Backups VM is still offline!" curl "http://10.10.100.12:8123/stopbackup" exit 1 fi echo "backups VM is online! Continuing with backup"