X-Git-Url: http://git.rot13.org/?p=sysadmin-cookbook;a=blobdiff_plain;f=recepies%2Fganeti%2Frestore-to-zfs-vol.sh;fp=recepies%2Fganeti%2Frestore-to-zfs-vol.sh;h=91a9d833e36e15e044b1069f4e686ef17f758075;hp=0000000000000000000000000000000000000000;hb=735359ae960c8ac718d50e5aec449c699ee73416;hpb=9b89d66043c9798798da848e92fe41ab97abb29c diff --git a/recepies/ganeti/restore-to-zfs-vol.sh b/recepies/ganeti/restore-to-zfs-vol.sh new file mode 100755 index 0000000..91a9d83 --- /dev/null +++ b/recepies/ganeti/restore-to-zfs-vol.sh @@ -0,0 +1,59 @@ +#!/bin/sh -e + +pool=workshop + +instance=koha.ffzg.hr +size=60G +instance=prod.vbz.ffzg.hr +instance=bookreader.rot13.org + +if [ -z "$1" ] ; then + zfs list -r $pool/block + echo + test -e "/mnt/*" && df -h /mnt/* | grep -v aufs + echo + du -hcs /$pool/ganeti/export/* | cut -d/ -f1,5 + exit 1 +else + instance=$1 +fi + +umount /mnt/$instance || true +zfs destroy $pool/block/$instance || true + +zfs create -V $size -b 4k -s $pool/block/$instance + +test -d /mnt/$instance || mkdir /mnt/$instance + +wait_for() { + echo -n "waiting for $1 " + while [ ! -e $1 ] ; do + echo -n . + sleep 1 + done + echo " found" +} + +wait_for /dev/zvol/$pool/block/$instance + +label=`echo $instance | cut -d. -f1` +echo "label $label = $instance" + +time mkfs.ext4 -m 0 -L $label /dev/zvol/$pool/block/$instance + +wait_for /dev/disk/by-label/$label + +mount /dev/disk/by-label/$label /mnt/$instance/ +cd /mnt/$instance/ +dump=`ls /$pool/ganeti/export/$instance/*.disk0*.snap` +ls -alh $dump +zpool iostat 2 | tee /dev/shm/$instance & +pid_iostat=$! +( while true; do zfs list $pool/block/$instance ; sleep 10 ; done ) & +pid_list=$! +time restore rf $dump +kill $pid_iostat +kill $pid_list + +wc -l /dev/shm/$instance +df -h /mnt/$instance