Whamcloud - gitweb
bc778e3e7c64a3c9d5d215ecfe397d7904c4903b
[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/demos/config.sh
6
7 [ ! -d $MNTSNAP/lost+found ] && echo "need to run snapsetup.sh first" && exit 1
8
9 plog umount $MNTSNAP
10 plog umount $MNTOBD
11
12 mount | grep "$MNTOBD " > /dev/null 2>&1
13 if [ x$? = x0 ]; then 
14     echo "Stuff still mounted on $MNTOBD; clean up first."
15     exit 
16 fi
17
18 mount | grep "$MNTSNAP " > /dev/null 2>&1
19 if [ x$? = x0 ]; then 
20     echo "Stuff still mounted on $MNTSNAP; clean up first."
21     exit 
22 fi
23
24 sync
25 plog log "STARTING snaprestore"
26
27
28 $OBDDIR/class/obdcontrol -f << EOF
29 device /dev/obd1
30 cleanup
31 detach
32 device /dev/obd2
33 connect
34 snaprestore 2 $SNAPTABLE 0
35 quit
36 EOF
37
38 plog log "COMPLETE snaprestore"
39
40 plog mount -t obdfs -odevice=/dev/obd2 none $MNTOBD