get pool name from running system
[sysadmin-cookbook] / recepies / ganeti / restore-to-zfs-vol.sh
index 5d2736f..9f6078d 100755 (executable)
@@ -1,6 +1,7 @@
 #!/bin/sh -e 
 
-pool=workshop
+pool=`zfs list -H -o name | head -1` # use first pool as target for zvol
+ganeti_export=/var/lib/ganeti/export
 
 size=60G
 vol_opt="-b 4k -s"
@@ -8,10 +9,10 @@ vol_opt="-b 4k -s"
 
 if [ -z "$1" ] ; then
        zfs list -r $pool/block
+#      echo
+#      test ! -z "/mnt/*" && df -h /mnt/* | grep -v aufs
        echo
-       test ! -z "/mnt/*" && df -h /mnt/* | grep -v aufs
-       echo
-       du -hcs /$pool/ganeti/export/* | cut -d/ -f1,5
+       du -hcs $ganeti_export/* | cut -d/ -f1,6 | sed 's,/,,'
        exit 1
 else
        instance=$1
@@ -44,7 +45,7 @@ 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`
+dump=`ls $ganeti_export/$instance/*.disk0*.snap`
 ls -alh $dump
 zpool iostat 2 | tee /dev/shm/$instance &
 pid_iostat=$!