a0fa43ce1859059d8447b944773efe342d9afb13
[xfstests-dev.git] / common.dump
1 ##/bin/sh
2
3 #
4 # Functions useful for xfsdump/xfsrestore tests
5 #
6 # Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
7
8 # This program is free software; you can redistribute it and/or modify it
9 # under the terms of version 2 of the GNU General Public License as
10 # published by the Free Software Foundation.
11
12 # This program is distributed in the hope that it would be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
16 # Further, this software is distributed without any warranty that it is
17 # free of the rightful claim of any third person regarding infringement
18 # or the like.  Any license provided herein, whether implied or
19 # otherwise, applies only to this software file.  Patent licenses, if
20 # any, provided herein do not apply to combinations of this program with
21 # other software, or any other product whatsoever.
22
23 # You should have received a copy of the GNU General Public License along
24 # with this program; if not, write the Free Software Foundation, Inc., 59
25 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
26
27 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
28 # Mountain View, CA  94043, or:
29
30 # http://www.sgi.com 
31
32 # For further information regarding this notice, see: 
33
34 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
35 #
36
37 # --- initializations ---
38 rm -f $seq.full
39
40 if [ -n "$DEBUGDUMP" ]; then
41   _dump_debug=-v5
42   _restore_debug=-v5
43   _invutil_debug=-d
44 fi
45  
46 # Use dump/restore in qa directory for debugging
47 #PATH=".:$PATH"
48 #export PATH
49 #which xfsdump
50 #which xfsrestore
51
52 # status returned for not run tests
53 NOTRUNSTS=2
54
55 # name those directories
56 dump_dir=$SCRATCH_MNT/dump.$$
57 dump_file=$tmp.dumpfile
58 dump_sdir=dump.$$
59 restore_dir=$SCRATCH_MNT/restore.$$
60 restore_sdir=restore.$$
61
62 dumptape=$TAPE_DEV
63 media_label="stress_tape_media"
64 session_label="stress_$seq"
65
66 nobody=4 # define this uid/gid as a number
67
68 _need_to_be_root
69
70 # install our cleaner
71 trap "_cleanup; exit \$status" 0 1 2 3 15
72
73 # start inventory from a known base - move it aside for test
74 if [ -d /var/xfsdump/inventory ]; then
75     if [ -d /var/xfsdump/inventory.$seq ]; then    
76         rm -rf /var/xfsdump/inventory.$seq
77     fi
78     mv /var/xfsdump/inventory /var/xfsdump/inventory.$seq
79 fi
80
81
82 #
83 # do a remote/local mt
84 #
85 _mt()
86 {
87     op=$1
88     if _isrmt; then  
89         # REMOTE
90         _rmtdev=`echo $dumptape | awk -F: '{print $2}'`
91
92         if echo $dumptape | grep '@' >/dev/null; then
93             _spec=`echo $dumptape | awk -F: '{print $1}'`
94             _rmtuser=`echo $_spec | awk -F@ '{print $1}'`
95             _rmthost=`echo $_spec | awk -F@ '{print $2}'`
96             rsh -n -l $_rmtuser $_rmthost "mt -t $_rmtdev $op"
97         else
98             _rmthost=`echo $dumptape | awk -F: '{print $1}'`
99             rsh -n $_rmthost "mt -t $_rmtdev $op"
100         fi
101     else
102         #LOCAL
103         mt -t $dumptape $op
104     fi
105 }
106
107 _check_onl()
108 {
109     _limit=10
110     i=0
111     while [ $i -lt $_limit ]; do  
112         echo "Checking online..." >>$seq.full
113         if _mt status >$tmp.status 2>&1; then
114             break; 
115         else
116             sleep 2 
117         fi
118         i=`expr $i + 1`
119     done
120
121
122     if [ $i -eq $_limit ]; then
123         echo "ERROR: mt -f $dumptape failed"
124         cat $tmp.status
125
126         echo "mt -f $dumptape failed" >$seq.notrun 
127         status=$NOTRUNSTS
128         exit
129     fi 
130
131
132     if egrep -i 'onl|ready' $tmp.status | grep -iv 'not ready' >/dev/null; then
133         :
134     else
135         echo "ERROR: $dumptape is not online"
136         cat $tmp.status
137
138         echo "dumptape, $dumptape, is not online" >$seq.notrun 
139         status=$NOTRUNSTS
140         exit
141     fi
142 }
143
144 _wait_tape()
145 {
146     echo "Wait for tape, $dumptape, ..." >>$seq.full
147
148     i=0
149     while [ $i -lt 20 ]; do  
150         echo "Checking status..." >>$seq.full
151         if _mt status 2>&1 | tee -a $seq.full | egrep -i "onl|ready" >/dev/null; then
152             break; 
153         else
154             sleep 2 
155         fi
156         i=`expr $i + 1`
157     done
158 }
159
160 #
161 # Keep trying so we know we really have rewound
162 #
163 _rewind()
164 {
165     echo "Initiate rewind..." >>$seq.full
166     _wait_tape
167     _mt rewind >/dev/null
168     _wait_tape
169 }
170
171 #
172 # Do a custom erase because: 
173 # (i) some machines don't support it
174 # (ii) some machines take forever to do it
175 #
176 _erase_soft()
177 {
178     echo "Erasing tape" | tee -a $seq.full
179     _rewind
180     _mt weof 3
181     _rewind
182 }
183
184 _erase_hard()
185 {
186     echo "Erasing tape" | tee -a $seq.full
187     _mt erase
188 }
189
190 _isrmt()
191 {
192     echo $dumptape | grep ':' >/dev/null
193 }
194
195 #
196 # Get tape ready
197 #
198 _set_variable()
199 {
200     if _isrmt; then
201         :
202     else
203         # LOCAL
204         echo "Put scsi tape driver into variable block size mode"
205         mt -f $dumptape setblk 0
206     fi  
207 }
208
209 _require_tape()
210 {
211     dumptape=$1
212
213     if [ -z "$dumptape" ]; then
214         echo "This test requires a dump tape - none was specified"
215         echo "No dump tape specified" >$seq.notrun 
216         status=$NOTRUNSTS
217         exit
218     fi
219
220     _check_onl
221     _set_variable
222 }
223
224 _error()
225 {
226     echo "Error: $*" | tee -a $seq.full
227     echo "(see $seq.full for details)"
228     status=1
229     exit
230 }
231
232 _wipe_fs()
233 {
234     _require_scratch
235
236     mkfs -t xfs -f $SCRATCH_DEV >>$seq.full  ||\
237         _error "mkfs failed"
238       
239     mount -t xfs $SCRATCH_DEV $SCRATCH_MNT >>$seq.full ||\
240         _error "mount failed"
241 }
242
243
244 # Cleanup created dirs and files
245 # Called by trap
246 #
247 _cleanup()
248 {
249     cd $here
250     rm -f $tmp.*
251
252     if [ -n "$DEBUGDUMP" ]; then
253         # save it for inspection
254         tar -zcvf $seq.inventory.tgz /var/xfsdump/inventory
255         ls -lR /var/xfsdump/inventory >$seq.inventory.ls
256     fi
257
258     # put inventory dir back
259     if [ -d /var/xfsdump/inventory.$seq ]; then
260         rm -rf /var/xfsdump/inventory # get rid of new one
261         mv /var/xfsdump/inventory.$seq /var/xfsdump/inventory
262     fi
263
264     if [ $status -ne $NOTRUNSTS ]; then
265         # Sleep added to stop _check_fs from complaining that the
266         # scratch_dev is still busy
267         sleep 10
268
269         _check_fs $SCRATCH_DEV
270     fi
271 }
272
273 _stable_fs()
274 {
275 #    umount $SCRATCH_MNT >/dev/null 
276 #    mount $SCRATCH_MNT >/dev/null
277     sync; sync; sleep 15
278 }
279
280 #
281 # Run src/fsstress to create a mixture of 
282 # files,dirs,links,symlinks
283 #
284 # Pinched from test 013.
285 #
286 _create_dumpdir_stress()
287 {
288     echo "Creating directory system to dump using src/fsstress."
289
290     _wipe_fs
291
292     _param="-f link=10 -f creat=10 -f mkdir=10 -f truncate=5 -f symlink=10"
293     _count=200
294     rm -rf $dump_dir
295     if ! mkdir $dump_dir; then
296         echo "    failed to mkdir $dump_dir"
297         status=1
298         exit
299     fi
300     echo ""
301     echo "-----------------------------------------------"
302     echo "fsstress : $_param"
303     echo "-----------------------------------------------"
304     if ! $here/src/fsstress $_param $FSSTRESS_AVOID -n $_count -d $dump_dir >$tmp.out 2>&1
305     then
306         echo "    fsstress (count=$_count) returned $? - see $seq.full"
307         
308         echo "--------------------------------------"       >>$here/$seq.full
309         echo "output from fsstress:"                        >>$here/$seq.full
310         echo "--------------------------------------"       >>$here/$seq.full
311         cat $tmp.out                                        >>$here/$seq.full
312         status=1
313     fi
314
315     _stable_fs
316 }
317
318 _mk_fillconfig1()
319 {
320     cat <<End-of-File >$tmp.config
321 # pathname      size in bytes   owner   group
322 #
323 small           10      $nobody $nobody
324 big             102400  daemon  sys
325 sub/small       10      bin     bin
326 sub/big         102400  $nobody sys
327 #
328 sub/a           1       $nobody $nobody
329 sub/b           2       $nobody $nobody
330 sub/c           4       $nobody $nobody
331 sub/d           8       $nobody $nobody
332 sub/e           16      $nobody $nobody
333 sub/f           32      $nobody $nobody
334 sub/g           64      $nobody $nobody
335 sub/h           128     $nobody $nobody
336 sub/i           256     $nobody $nobody
337 sub/j           512     $nobody $nobody
338 sub/k           1024    $nobody $nobody
339 sub/l           2048    $nobody $nobody
340 sub/m           4096    $nobody $nobody
341 sub/n           8192    $nobody $nobody
342 #
343 sub/a00         100     $nobody $nobody
344 sub/b00         200     $nobody $nobody
345 sub/c00         400     $nobody $nobody
346 sub/d00         800     $nobody $nobody
347 sub/e00         1600    $nobody $nobody
348 sub/f00         3200    $nobody $nobody
349 sub/g00         6400    $nobody $nobody
350 sub/h00         12800   $nobody $nobody
351 sub/i00         25600   $nobody $nobody
352 sub/j00         51200   $nobody $nobody
353 sub/k00         102400  $nobody $nobody
354 sub/l00         204800  $nobody $nobody
355 sub/m00         409600  $nobody $nobody
356 sub/n00         819200  $nobody $nobody
357 #
358 sub/a000        1000    $nobody $nobody
359 sub/e000        16000   $nobody $nobody
360 sub/h000        128000  $nobody $nobody
361 sub/k000        1024000 $nobody $nobody
362 End-of-File
363 }
364
365 _mk_fillconfig2()
366 {
367     cat <<End-of-File >$tmp.config
368 # pathname      size in bytes
369 #
370 smalll          10      $nobody $nobody
371 biggg           102400  $nobody $nobody
372 sub/smalll      10      $nobody $nobody
373 sub/biggg       102400  $nobody $nobody
374 End-of-File
375 }
376
377 #
378 # Create a bunch of directories/files of different sizes
379 # filled with data.
380 #
381 # Pinched from test 001.
382 #
383 _do_create_dumpdir_fill()
384 {
385     echo "Creating directory system to dump using src/fill."
386
387     if mkdir -p $dump_dir
388     then
389         :
390     else
391         echo "Error: cannot mkdir \"$dump_dir\""
392         exit 1
393     fi
394     cd $dump_dir
395
396     $verbose && echo -n "Setup "
397     sed -e '/^#/d' $tmp.config \
398     | while read file nbytes owner group perms
399     do
400         dir=`dirname $file`
401         if [ "$dir" != "." ]
402         then
403             if [ ! -d $dir ]
404             then
405                 if mkdir $dir
406                 then
407                     :
408                 else
409                     $verbose && echo
410                     echo "Error: cannot mkdir \"$dir\""
411                     exit 1
412                 fi
413             fi
414         fi
415         rm -f $file
416         if $here/src/fill $file $file $nbytes
417         then
418             :
419         else
420             $verbose && echo
421             echo "Error: cannot create \"$file\""
422             exit 1
423         fi
424         if [ -n "$owner" -a -n "$group" ]; then
425             chown $owner.$group $file
426         fi
427         if [ -n "$perms" ]; then
428             chmod $perms $file
429         fi
430         $verbose && echo -n "."
431     done
432     $verbose && echo
433
434     cd $here
435 }
436
437
438 _create_dumpdir_fill()
439 {
440     _wipe_fs
441     _mk_fillconfig1
442     _do_create_dumpdir_fill
443     _stable_fs
444 }       
445
446 _create_dumpdir_fill2()
447 {
448     _wipe_fs
449     _mk_fillconfig2
450     _do_create_dumpdir_fill
451     _stable_fs
452 }       
453
454
455
456 #
457 # Append a subset of the fill'ed files
458 # So we can see if just these get dumped on an incremental
459 #
460 _append_dumpdir_fill()
461 {
462     cd $dump_dir
463     cat <<End-of-File >$tmp.config
464 # pathname
465 #
466 small   
467 sub/big 
468 #
469 sub/a
470 sub/c
471 sub/e
472 End-of-File
473     sed -e '/^#/d' $tmp.config \
474     | while read file
475     do
476         echo 'Extra text' >>$file
477     done
478
479     cd $here
480 }
481
482 _do_create_dump_symlinks()
483 {
484     echo "Creating directory system of symlinks to dump."
485
486     if mkdir -p $dump_dir
487     then
488         :
489     else
490         echo "Error: cannot mkdir \"$dump_dir\""
491         exit 1
492     fi
493     cd $dump_dir
494
495     $verbose && echo -n "Setup "
496     sed -e '/^#/d' $tmp.config \
497     | while read file nbytes owner group owner2 group2 perms perms2
498     do
499         dir=`dirname $file`
500         if [ "$dir" != "." ]
501         then
502             if [ ! -d $dir ]
503             then
504                 if mkdir $dir
505                 then
506                     :
507                 else
508                     $verbose && echo
509                     echo "Error: cannot mkdir \"$dir\""
510                     exit 1
511                 fi
512             fi
513         fi
514         rm -f $file
515         touch $file
516
517         # Do chmod on symlink using umask.
518         # This won't do the right thing as it subtracts permissions.
519         # However, I don't care, as long as I get some different perms
520         # for testing.
521         if [ -n "$perms2" ]; then
522             omask=`umask`
523             umask $perms2
524         fi
525         ln -s $file $file-link
526         if [ -n "$perms2" ]; then
527             umask $omask        
528         fi
529
530         if [ -n "$owner" -a -n "$group" ]; then
531             chown $owner.$group $file
532         fi
533         if [ -n "$owner" -a -n "$group" ]; then
534             chown -h $owner.$group $file-link
535         fi
536         if [ -n "$perms" ]; then
537             chmod $perms $file
538         fi
539         $verbose && echo -n "."
540     done
541     $verbose && echo
542
543     cd $here
544 }
545
546 _mk_symlink_config()
547 {
548     cat <<End-of-File >$tmp.config
549 # path  size    owner1  group1  owner2  group2  perm1   perm2 
550 #
551 a       0       $nobody $nobody daemon  sys     124     421
552 b       0       daemon  sys     bin     bin     347     743
553 sub/a   0       bin     bin     $nobody sys     777     777
554 sub/b   0       $nobody sys     $nobody $nobody 367     763
555 End-of-File
556 }
557
558 _create_dumpdir_symlinks()
559 {
560     _wipe_fs
561     _mk_symlink_config
562     _do_create_dump_symlinks
563     _stable_fs
564 }       
565
566 #
567 # Filter for ls
568 # Filter out dates on symlinks
569 #
570 _ls_filter()
571 {
572   $AWK_PROG '/^l/ { date = $8; sub(date,"DATE"); print}
573         {print}' \
574   | sed -e 's/total [0-9][0-9]*/total TOTAL/'
575 }
576
577
578
579 # Filter out the non-deterministic dump msgs from
580 # xfsdump and xfsrestore
581 #
582 _dump_filter()
583 {
584   sed \
585       -e "s/`hostname`/HOSTNAME/"   \
586       -e "s#$SCRATCH_DEV#SCRATCH_DEV#"    \
587       -e "s#$dumptape#TAPE_DEV#"    \
588       -e "s#$SCRATCH_MNT#SCRATCH_MNT#"    \
589       -e "s#$dump_file#DUMP_FILE#"  \
590       -e 's/id:[        ]*[0-9a-f-]*/id: ID/'  \
591       -e 's/time:[      ].*/time: TIME/'       \
592       -e 's/date:[      ].*/date: DATE/'       \
593       -e 's/dump begun .*/dump begun DATE/'    \
594       -e 's/[0-9][0-9]* seconds/SECS seconds/' \
595       -e '/: dump size/s/[1-9][0-9]*/NUM/'     \
596       -e '/dump size:/s/[1-9][0-9]*/NUM/'      \
597       -e '/media file size/s/[1-9][0-9]*/NUM/' \
598       -e '/\/dev\/tty/d' \
599       -e '/inventory session uuid/d' \
600
601 }
602
603 _invutil_filter()
604 {
605   _dump_filter \
606   | sed \
607         -e 's/UUID[     ]*:[    ][0-9a-f-]*/UUID                :       ID/' \
608         -e 's/TIME OF DUMP[     ]*:.*/TIME OF DUMP      :       TIME/' \
609         -e 's/HOSTNAME:SCRATCH_MNT.*/HOSTNAME:SCRATCH_MNT/' \
610         -e 's#inventory/[0-9a-f-]*#inventory/UUID#' \
611
612 }
613
614 _dir_filter()
615 {
616   sed \
617     -e "s#$dump_file#DUMP_FILE#"      \
618     -e "s#$SCRATCH_DEV#SCRATCH_DEV#"        \
619     -e "s#$dumptape#TAPE_DEV#"         \
620     -e "s#$dump_dir#DUMP_DIR#g"       \
621     -e "s#$restore_dir#RESTORE_DIR#g" \
622     -e "s#$SCRATCH_MNT#SCRATCH_MNT#g"       \
623     -e "s#$dump_sdir#DUMP_SUBDIR#g"   \
624     -e "s#$restore_sdir#RESTORE_SUBDIR#g" \
625
626 }
627
628 _parse_args()
629 {
630     OPTIND=0
631     dump_args=""
632     while getopts "f:FL:o" c $*
633     do
634         case $c
635         in
636         f)
637             [ -z "$OPTARG" ] && _error "missing argument for -f"
638             dumptape=$OPTARG    
639             ;;
640         L)
641             [ -z "$OPTARG" ] && _error "missing argument for -L"
642             session_label=$OPTARG       
643             ;;
644         o)
645             dump_args="$dump_args -o"
646             ;;
647         F)
648             dump_args="$dump_args -F"
649             ;;
650         \?)
651             _error "invalid argument"
652             ;;
653         esac
654     done
655 }
656
657
658 #
659 # Dump a subdir
660 #
661 _do_dump_sub()
662 {
663     _parse_args $*
664
665     echo "Dumping to tape..."
666     opts="$_dump_debug$dump_args -s $dump_sdir -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
667     echo "xfsdump $opts" | _dir_filter  
668     xfsdump $opts 2>&1 | tee -a $seq.full | _dump_filter
669 }
670
671 #
672 # Do full level 0 dump
673 #
674 _do_dump()
675 {
676     _parse_args $*
677
678     echo "Dumping to tape..."
679     opts="$_dump_debug$dump_args -l0 -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
680     echo "xfsdump $opts" | _dir_filter  
681     xfsdump $opts 2>&1 | tee -a $seq.full | _dump_filter
682 }
683
684
685 #
686 # Do full dump with -m
687 #
688 _do_dump_min()
689 {
690     _parse_args $*
691
692     echo "Dumping to tape..."
693     onemeg=1048576
694     opts="$_dump_debug$dump_args -m -b $onemeg -l0 -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
695     echo "xfsdump $opts" | _dir_filter  
696     xfsdump $opts 2>&1 | tee -a $seq.full | _dump_filter
697 }
698
699 #
700 # Do level 1 incremental dump
701 #
702 _do_dump_incremental()
703 {
704     _parse_args $*
705
706     echo "Dumping incrementally to tape..."
707     opts="$_dump_debug$dump_args -l1 -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
708     echo "xfsdump $opts" | _dir_filter  
709     xfsdump $opts 2>&1 | tee -a $seq.full | _dump_filter
710 }
711
712 #
713 # Do full dump to file
714 #
715 _do_dump_file()
716 {
717     _parse_args $*
718
719     echo "Dumping to file..."
720     opts="$_dump_debug$dump_args -f $dump_file -M $media_label -L $session_label $SCRATCH_MNT"
721     echo "xfsdump $opts" | _dir_filter  
722     xfsdump $opts 2>&1 | tee -a $seq.full | _dump_filter
723 }
724
725
726 _prepare_restore_dir()
727 {
728     rm -rf $restore_dir
729     if ! mkdir $restore_dir; then
730         echo "    failed to mkdir $restore_dir"
731         status=1
732         exit
733     fi
734 }
735
736
737 #
738 # Get tape ready and restore dir
739 #
740 _prepare_restore()
741 {
742     _prepare_restore_dir
743
744     echo "Rewinding tape"
745     _rewind
746 }
747
748 #
749 # Restore the tape into $restore_dir
750 #
751 _do_restore()
752 {
753     _parse_args $*
754     _prepare_restore
755
756
757     echo "Restoring from tape..."
758     opts="$_restore_debug$dump_args -f $dumptape  -L $session_label $restore_dir"
759     echo "xfsrestore $opts" | _dir_filter  
760     xfsrestore $opts 2>&1 | tee -a $seq.full | _dump_filter
761 }
762
763 #
764 # Restore the tape into $restore_dir using -m
765 #
766 _do_restore_min()
767 {
768     _parse_args $*
769     _prepare_restore
770
771     echo "Restoring from tape..."
772     onemeg=1048576
773     opts="$_restore_debug$dump_args -m -b $onemeg -f $dumptape  -L $session_label $restore_dir"
774     echo "xfsrestore $opts" | _dir_filter  
775     xfsrestore $opts 2>&1 | tee -a $seq.full | _dump_filter
776 }
777
778 #
779 # Restore the tape from a dump file
780 #
781 _do_restore_file()
782 {
783     _parse_args $*
784     _prepare_restore_dir
785
786     echo "Restoring from file..."
787     opts="$_restore_debug$dumpargs -f $dump_file  -L $session_label $restore_dir"
788     echo "xfsrestore $opts" | _dir_filter  
789     xfsrestore $opts 2>&1 | tee -a $seq.full | _dump_filter
790 }
791
792 #
793 # Do xfsdump piped into xfsrestore - xfsdump | xfsrestore
794 #
795 # Use -s as we want to dump and restore to the same xfs partition
796 #
797 _do_dump_restore()
798 {
799     _parse_args $*
800     _prepare_restore_dir
801     echo "xfsdump|xfsrestore ..."
802     restore_opts="$_restore_debug - $restore_dir"
803     dump_opts="$_dump_debug$dump_args -s $dump_sdir - $SCRATCH_MNT"
804     echo "xfsdump $dump_opts | xfsrestore $restore_opts" | _dir_filter  
805     xfsdump $dump_opts 2>$tmp.dump.mlog | xfsrestore $restore_opts 2>&1 | tee -a $seq.full | _dump_filter
806     _dump_filter <$tmp.dump.mlog
807 }
808
809 #
810 # Compare dumped subdirectory with restored dir
811 # using ls -lR.
812 # Thus no contents are compared but permissions, sizes,
813 # owners, etc... are.
814 #
815 _ls_compare_sub()
816 {
817     #
818     # verify we got back what we dumped
819     #
820     echo "Comparing listing of dump directory with restore directory"
821     ls -lR $dump_dir | tee -a $seq.full | _ls_filter >$tmp.dump_dir
822     ls -lR $restore_dir/$dump_sdir | tee -a $seq.full | _ls_filter \
823     | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
824
825     diff -cs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
826 }
827
828
829 #
830 # Compare using recursive diff the files of the dumped
831 # subdirectory.
832 # This one will compare the contents.
833 #
834 _diff_compare_sub()
835 {
836     echo "Comparing dump directory with restore directory"
837     diff -rs $dump_dir $restore_dir/$dump_sdir | _dir_filter
838 }
839
840 #
841 # Compare using recursive diff the files of the dumped
842 # filesystem
843 #
844 _diff_compare()
845 {
846     echo "Comparing dump directory with restore directory"
847     diff -rs $SCRATCH_MNT $restore_dir | _dir_filter
848 }
849
850 #
851 # Check out the dump inventory
852 #
853 _dump_inventory()
854 {
855     xfsdump $_dump_debug -I | tee -a $seq.full | _dump_filter 
856 }
857
858 #
859 # Do the xfsinvutil cmd with debug and filters
860 # Need to set variable: "$middate" to the invutil date 
861 #
862 _do_invutil()
863 {
864     host=`hostname`
865     echo "xfsinvutil $_invutil_debug -M $host:$SCRATCH_MNT \"$middate\" $*" >$seq.full
866     xfsinvutil $_invutil_debug -M $host:$SCRATCH_MNT "$middate" $* \
867     | tee -a $seq.full | _invutil_filter
868 }
869
870 # make sure this script returns success
871 /bin/true