Whamcloud - gitweb
Fixes to shell scripts to check for errors and other improvements
[fs/lustre-release.git] / lustre / demos / snaprest.sh
1 #!/bin/sh
2 # Utility script to test restoring a previous snapshot.  This will destroy
3 # the "current" snapshot and restore the old one in its place.
4 OBDDIR="`dirname $0`/.."
5 [ "$OBDDIR" = "./.." ] && OBDDIR=".."
6 . $OBDDIR/demos/config.sh
7
8 [ ! -d $MNTSNAP/lost+found ] && echo "need to run snapsetup.sh first" && exit 1
9
10 plog umount $MNTSNAP
11 plog umount $MNTOBD
12
13 mount | grep $MNTOBD > /dev/null 2>&1
14 if [ x$? = x0 ]; then 
15     echo "Stuff still mounted on $MNTOBD; clean up first."
16     exit 
17 fi
18
19 mount | grep $MNTSNAP > /dev/null 2>&1
20 if [ x$? = x0 ]; then 
21     echo "Stuff still mounted on $MNTSNAP; clean up first."
22     exit 
23 fi
24
25 sync
26 plog log "STARTING snaprestore"
27
28
29 $OBDDIR/class/obdcontrol -f << EOF
30 device /dev/obd1
31 cleanup
32 detach
33 device /dev/obd2
34 connect
35 snaprestore 2 $SNAPTABLE 0
36 EOF
37
38 plog log "COMPLETE snaprestore"
39
40 plog mount -t obdfs -odevice=/dev/obd2 none $MNTOBD