5 test -z "$backup" && backup="backup"
7 if [ "$1" = '-' ] ; then
9 elif [ -z "$instance" -o -z "$disk" ] ; then
10 echo "Usage: $0 instance disk"
14 test -z "$instance" && exit 1
16 instance=`gnt-instance list --no-headers -o name $instance | head -1`
18 node=`gnt-instance list -o pnode --no-headers $instance`
19 echo "# $instance on $node"
21 vg=`gnt-cluster info | grep 'lvm volume group:' | cut -d: -f2 | tr -d ' '`
23 ssh $node lvs -o name,tags | grep $instance | tee /dev/shm/$instace.$node.lvs | grep disk${disk}_data | while read lv origin ; do
24 disk_nr=`echo $lv | cut -d. -f2 | tr -d a-z_`
25 echo "# $lv | $origin | $disk_nr"
28 if rsync lib15::$backup/$instance/rsync.args /dev/shm/$instance-rsync.args ; then
29 rsync_args="`cat /dev/shm/$instance-rsync.args`"
32 cat <<__SHELL__ > /dev/shm/$instance.sh
34 lvcreate -L20480m -s -n$lv.snap /dev/$vg/$lv
36 mkdir /dev/shm/$lv.snap
38 # we must mount filesystem read-write to allow journal recovery
39 offset=\`fdisk -l /dev/$vg/$lv.snap -u | grep Linux$ | grep /dev/$vg/$lv.snap | head -1 | sed 's/\*/ /' | awk '{ print \$2 * 512 }'\`
40 test ! -z "\$offset" && offset=",offset=\$offset"
41 mount /dev/$vg/$lv.snap /dev/shm/$lv.snap -o noatime\$offset
43 rsync -ravHzXA --inplace --numeric-ids --delete $rsync_args /dev/shm/$lv.snap/ lib15::$backup/$instance/$disk_nr/
45 umount /dev/shm/$lv.snap
47 lvremove -f /dev/$vg/$lv.snap
49 rmdir /dev/shm/$lv.snap
50 rm -v /dev/shm/$instance.sh
53 scp /dev/shm/$instance.sh $node:/dev/shm/$instance.sh
55 ssh $node sh -xe /dev/shm/$instance.sh
57 # execute zfs snap on lib15 via ssh command="" wrapper
58 ssh -i /root/.ssh/id_dsa-zfs lib15 lib15/$backup/$instance/$disk_nr