-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvm_backup.sh
executable file
·42 lines (35 loc) · 930 Bytes
/
vm_backup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh
# Defining log
LOG=/home/fille/Loggar/miniserver.txt
touch $LOG
exec >> $LOG 2>&1
echo ""
echo "Starting backup $(date "+%Y-%m-%d %H:%M")"
echo "----------------------------"
# Suspend machines on miniserver
ssh root@miniserver "/suspend.sh"
ssh root@miniserver "cat /tmp/miniserver_suspend.txt"
ssh root@miniserver "rm /tmp/miniserver_suspend.txt"
echo ""
# Backup machines
scp -r root@miniserver:/vmfs/volumes/830_1/ /mnt/storage/vms/
if [ $? == 0 ]
then
echo "830_1 succeeded."
else
echo "830_1 failed!"
fi
scp -r root@miniserver:/vmfs/volumes/830_2/ /mnt/storage/vms/
if [ $? == 0 ]
then
echo "830_2 succeeded."
else
echo "830_2 failed!"
fi
echo ""
# Starting machines on miniserver
ssh root@miniserver "/start.sh"
ssh root@miniserver "cat /tmp/miniserver_start.txt"
ssh root@miniserver "rm /tmp/miniserver_start.txt"
echo "----------------------------"
echo "Backup finished $(date "+%Y-%m-%d %H:%M")"