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"
23 ssh $node lvs -o name,tags,vg_name | grep $instance | tee /dev/shm/$instace.$node.lvs | grep disk${disk}_data | while read lv origin vg ; do
26 disk_nr=`echo $lv | cut -d. -f2 | tr -d a-z_`
27 echo "# $lv | $origin | $disk_nr"
29 cat <<__SHELL__ > /dev/shm/$instance-mount.sh
31 lvcreate -L10240m -s -n$lv.snap /dev/$vg/$lv
33 mkdir /dev/shm/$lv.snap
35 # we must mount filesystem read-write to allow journal recovery
36 offset=\`fdisk -l /dev/$vg/$lv.snap -u | grep Linux | grep /dev/$vg/$lv.snap | head -1 | sed 's/\*/ /' | awk '{ print \$2 * 512 }'\`
37 test ! -z "\$offset" && offset=",offset=\$offset"
38 mount /dev/$vg/$lv.snap /dev/shm/$lv.snap -o noatime\$offset
40 echo "rsync-from $node:/dev/shm/$lv.snap/"
44 cat <<__SHELL__ > /dev/shm/$instance-umount.sh
45 umount /dev/shm/$lv.snap
47 lvremove -f /dev/$vg/$lv.snap
49 rmdir /dev/shm/$lv.snap
52 scp /dev/shm/$instance-*.sh $node:/dev/shm/
54 ssh $node sh -xe /dev/shm/$instance-mount.sh
56 echo "ssh $node sh -xe /dev/shm/$instance-umount.sh"