Files
backup-scripts/start-backup.sh
2025-08-26 22:15:01 +02:00

36 lines
799 B
Bash
Executable File

#!/bin/bash
if [ $# -ne 0 ]
then
echo "Running backup $1 script at $(date)"
else
echo "Running backup script at $(date)"
fi
echo "running backup $SERVICE script at $(date)"
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"