Zuletzt aktiv 6 months ago

waja hat die Gist bearbeitet 3 years ago. Zu Änderung gehen

1 file changed, 74 insertions

xen_vm_sync(Datei erstellt)

@@ -0,0 +1,74 @@
1 + #!/bin/sh
2 + host=$1; shift;
3 + vmHost=$1; shift;
4 +
5 + # How many Pings send to check the Default Gateway
6 + PINGCOUNT="5"
7 + # When should check_icmp gets faulty, see check_icmp --help
8 + FAULT="5000,100%"
9 + # Timeout for ping checks
10 + TIMEOUT="30"
11 +
12 + sshPath="/usr/bin/ssh"
13 + DumpPreUserCmd="$sshPath -q -x -l root ${host} /usr/share/backuppc-helper/lvm_pre_backup ${vmHost}"
14 + DumpPostUserCmd="$sshPath -q -x -l root ${host} /usr/share/backuppc-helper/lvm_post_backup ${vmHost}"
15 +
16 + if [ -f /etc/default/backuppc-helper ]
17 + then
18 + . /etc/default/backuppc-helper
19 + if [ -z "$VOL" ]
20 + then
21 + echo "#### WARNING ####"
22 + echo "VOL in /etc/default/backuppc-helper not set!"
23 + echo "#################"
24 + exit 0
25 + fi
26 + else
27 + echo "#### WARNING ####"
28 + echo "/etc/default/backuppc-helper is missing!"
29 + echo "#################"
30 + exit 0
31 + fi
32 +
33 + if [ `mount | grep ${vmHost} | wc -l` -gt "0" ] ; then
34 + echo "#### WARNING ####"
35 + echo "/dev/${VOL}/${vmHost}-disk already mounted!"
36 + echo "#################"
37 + exit 0
38 + fi
39 +
40 + # is the check_icmp binary there?
41 + if [ ! -e /usr/lib/nagios/plugins/check_icmp ]; then
42 + echo "#### ERROR ####"
43 + echo "check_icmp not found! Is nagios-plugins-basic installed?"
44 + echo "###############"
45 + exit 1
46 + fi
47 +
48 + # check
49 + /usr/lib/nagios/plugins/check_icmp -n ${PINGCOUNT} -t ${TIMEOUT} -w ${FAULT} -c ${FAULT} -H ${host} > /dev/null || unreach="true"
50 + if [ ${unreach} ] ; then
51 + echo "#### ERROR ####"
52 + echo "$host not reachable!"
53 + echo "###############"
54 + exit 1
55 + fi
56 +
57 + # create directory
58 + mkdir -p /mnt/${vmHost}
59 +
60 + # mount target fs
61 + mount /dev/${VOL}/${vmHost}-disk /mnt/${vmHost}
62 +
63 + # mount snapshot of source fs on remote system
64 + $DumpPreUserCmd
65 +
66 + # sync remote filesystem with local once
67 + rsync -az --numeric-ids --delete root@${host}:/mnt/${vmHost}/ /mnt/${vmHost}/
68 + rsync -az --numeric-ids --delete root@${host}:/etc/xen/${vmHost}* /etc/xen/
69 +
70 + # umount snapshot of source fs on remote system
71 + $DumpPostUserCmd
72 +
73 + # umount target fs
74 + umount /mnt/${vmHost}
Neuer Älter