/[sysadmin-cookbook]/recepies/ganeti/restore-to-zfs-vol.sh
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /recepies/ganeti/restore-to-zfs-vol.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 321 - (hide annotations)
Mon Jun 23 09:50:59 2014 UTC (9 years, 10 months ago) by dpavlin
File MIME type: application/x-sh
File size: 1158 byte(s)
configurable vol_opt (e.g. compression)

1 dpavlin 320 #!/bin/sh -e
2    
3     pool=workshop
4    
5     size=60G
6 dpavlin 321 vol_opt="-b 4k -s"
7     #vol_opt="-b 4k -s -o compression=lz4"
8 dpavlin 320
9     if [ -z "$1" ] ; then
10     zfs list -r $pool/block
11     echo
12 dpavlin 321 test ! -z "/mnt/*" && df -h /mnt/* | grep -v aufs
13 dpavlin 320 echo
14     du -hcs /$pool/ganeti/export/* | cut -d/ -f1,5
15     exit 1
16     else
17     instance=$1
18     fi
19    
20     umount /mnt/$instance || true
21     zfs destroy $pool/block/$instance || true
22    
23 dpavlin 321 zfs create -V $size $vol_opt $pool/block/$instance
24 dpavlin 320
25     test -d /mnt/$instance || mkdir /mnt/$instance
26    
27     wait_for() {
28     echo -n "waiting for $1 "
29     while [ ! -e $1 ] ; do
30     echo -n .
31     sleep 1
32     done
33     echo " found"
34     }
35    
36     wait_for /dev/zvol/$pool/block/$instance
37    
38     label=`echo $instance | cut -d. -f1`
39     echo "label $label = $instance"
40    
41     time mkfs.ext4 -m 0 -L $label /dev/zvol/$pool/block/$instance
42    
43     wait_for /dev/disk/by-label/$label
44    
45     mount /dev/disk/by-label/$label /mnt/$instance/
46     cd /mnt/$instance/
47     dump=`ls /$pool/ganeti/export/$instance/*.disk0*.snap`
48     ls -alh $dump
49     zpool iostat 2 | tee /dev/shm/$instance &
50     pid_iostat=$!
51     ( while true; do zfs list $pool/block/$instance ; sleep 10 ; done ) &
52     pid_list=$!
53     time restore rf $dump
54     kill $pid_iostat
55     kill $pid_list
56    
57     wc -l /dev/shm/$instance
58     df -h /mnt/$instance

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26