Whamcloud - gitweb
71753895e3f2ae133c09d799255268b0c1615c6b
[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 sync
14 sleep 1
15 plog log "STARTING snaprestore"
16 # To do a snapshot restore at this time, we need to do several steps.  In
17 # the future, this should all be wrapped into the snaprestore function.
18 # - we reverse the current and restored entries in the snapshot table
19 # - we proceed to delete the previous current snapshot
20 # - we unconfigure the previous current snapshot
21 # - we delete the previous current snapshot from the table and load it
22 $OBDDIR/class/obdcontrol -f << EOF
23 XXX need to reverse current/restored entries here!!!
24 snapset 0 $SNAPTABLE
25 device /dev/obd2
26 connect
27 snaprestore 1
28 device /dev/obd1
29 cleanup
30 detach
31 snaptable
32 $SNAPTABLE
33 d
34 1
35 q
36 y
37 snapset 0 $SNAPTABLE
38 EOF
39 plog log "COMPLETE snaprestore"
40
41 plog mount -t obdfs -odevice=/dev/obd2 /dev/obd2 $MNTOBD