76de90618ca72f0e44f6033d06061b07ad9f1d6b
[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 _mk_fillconfig_perm()
378 {
379     cat <<End-of-File >$tmp.config
380 # pathname      size/dir  user group mode
381 #
382 file_suid       10      $nobody $nobody 04777
383 file_guid       10      $nobody $nobody 02777
384 file_sticky     10      $nobody $nobody 01777
385 file_mix1       10      $nobody $nobody 761
386 file_mix2       10      $nobody $nobody 642
387 dir_suid        d       $nobody $nobody 04777
388 dir_guid        d       $nobody $nobody 02777
389 dir_sticky      d       $nobody $nobody 01777
390 dir_mix1        d       $nobody $nobody 761
391 dir_mix2        d       $nobody $nobody 642
392 End-of-File
393 }
394
395 #
396 # Create a bunch of directories/files of different sizes
397 # filled with data.
398 #
399 # Pinched from test 001.
400 #
401 _do_create_dumpdir_fill()
402 {
403     echo "Creating directory system to dump using src/fill."
404
405     if mkdir -p $dump_dir
406     then
407         :
408     else
409         echo "Error: cannot mkdir \"$dump_dir\""
410         exit 1
411     fi
412     cd $dump_dir
413
414     $verbose && echo -n "Setup "
415     sed -e '/^#/d' $tmp.config \
416     | while read file nbytes owner group perms
417     do
418         if [ $nbytes = "d" ]; then
419             # create a directory
420             dir=$file   
421             if [ ! -d $dir ]
422             then
423                 if mkdir $dir
424                 then
425                     :
426                 else
427                     $verbose && echo
428                     echo "Error: cannot mkdir \"$dir\""
429                     exit 1
430                 fi
431             fi
432         else
433             # create a directory/file
434             dir=`dirname $file`
435             if [ "$dir" != "." ]
436             then
437                 if [ ! -d $dir ]
438                 then
439                     if mkdir $dir
440                     then
441                         :
442                     else
443                         $verbose && echo
444                         echo "Error: cannot mkdir \"$dir\""
445                         exit 1
446                     fi
447                 fi
448             fi
449             rm -f $file
450             if $here/src/fill $file $file $nbytes
451             then
452                 :
453             else
454                 $verbose && echo
455                 echo "Error: cannot create \"$file\""
456                 exit 1
457             fi
458         fi
459         if [ -n "$owner" -a -n "$group" ]; then
460             chown $owner.$group $file
461         fi
462         if [ -n "$perms" ]; then
463             chmod $perms $file
464         fi
465         $verbose && echo -n "."
466     done
467     $verbose && echo
468
469     cd $here
470 }
471
472
473 _create_dumpdir_fill()
474 {
475     _wipe_fs
476     _setup_seq_out
477     _mk_fillconfig1
478     _do_create_dumpdir_fill
479     _stable_fs
480 }       
481
482 _create_dumpdir_fill2()
483 {
484     _wipe_fs
485     _setup_seq_out
486     _mk_fillconfig2
487     _do_create_dumpdir_fill
488     _stable_fs
489 }       
490
491 _create_dumpdir_fill_perm()
492 {
493     _wipe_fs
494     _setup_seq_out
495     _mk_fillconfig_perm
496     _do_create_dumpdir_fill
497     _stable_fs
498 }       
499
500
501
502 #
503 # Append a subset of the fill'ed files
504 # So we can see if just these get dumped on an incremental
505 #
506 _append_dumpdir_fill()
507 {
508     cd $dump_dir
509     cat <<End-of-File >$tmp.config
510 # pathname
511 #
512 small   
513 sub/big 
514 #
515 sub/a
516 sub/c
517 sub/e
518 End-of-File
519     sed -e '/^#/d' $tmp.config \
520     | while read file
521     do
522         echo 'Extra text' >>$file
523     done
524
525     cd $here
526 }
527
528 _do_create_dump_symlinks()
529 {
530     echo "Creating directory system of symlinks to dump."
531
532     if mkdir -p $dump_dir
533     then
534         :
535     else
536         echo "Error: cannot mkdir \"$dump_dir\""
537         exit 1
538     fi
539     cd $dump_dir
540
541     $verbose && echo -n "Setup "
542     sed -e '/^#/d' $tmp.config \
543     | while read file nbytes owner group owner2 group2 perms perms2
544     do
545         dir=`dirname $file`
546         if [ "$dir" != "." ]
547         then
548             if [ ! -d $dir ]
549             then
550                 if mkdir $dir
551                 then
552                     :
553                 else
554                     $verbose && echo
555                     echo "Error: cannot mkdir \"$dir\""
556                     exit 1
557                 fi
558             fi
559         fi
560         rm -f $file
561         touch $file
562
563         # Do chmod on symlink using umask.
564         # This won't do the right thing as it subtracts permissions.
565         # However, I don't care, as long as I get some different perms
566         # for testing.
567         if [ -n "$perms2" ]; then
568             omask=`umask`
569             umask $perms2
570         fi
571         ln -s $file $file-link
572         if [ -n "$perms2" ]; then
573             umask $omask        
574         fi
575
576         if [ -n "$owner" -a -n "$group" ]; then
577             chown $owner.$group $file
578         fi
579         if [ -n "$owner" -a -n "$group" ]; then
580             chown -h $owner.$group $file-link
581         fi
582         if [ -n "$perms" ]; then
583             chmod $perms $file
584         fi
585         $verbose && echo -n "."
586     done
587     $verbose && echo
588
589     cd $here
590 }
591
592 _mk_symlink_config()
593 {
594     cat <<End-of-File >$tmp.config
595 # path  size    owner1  group1  owner2  group2  perm1   perm2 
596 #
597 a       0       $nobody $nobody daemon  sys     124     421
598 b       0       daemon  sys     bin     bin     347     743
599 sub/a   0       bin     bin     $nobody sys     777     777
600 sub/b   0       $nobody sys     $nobody $nobody 367     763
601 End-of-File
602 }
603
604 _create_dumpdir_symlinks()
605 {
606     _wipe_fs
607     _mk_symlink_config
608     _do_create_dump_symlinks
609     _stable_fs
610 }       
611
612 #
613 # Filter for ls
614 # Filter out dates on symlinks
615 #
616 _ls_filter()
617 {
618   $AWK_PROG '/^l/ { date = $8; sub(date,"DATE"); print}
619         {print}' \
620   | sed -e 's/total [0-9][0-9]*/total TOTAL/'
621 }
622
623
624
625 # Filter out the non-deterministic dump msgs from
626 # xfsdump and xfsrestore
627 #
628 _dump_filter()
629 {
630   sed \
631       -e "s/`hostname`/HOSTNAME/"   \
632       -e "s#$SCRATCH_DEV#SCRATCH_DEV#"    \
633       -e "s#$dumptape#TAPE_DEV#"    \
634       -e "s#$SCRATCH_MNT#SCRATCH_MNT#"    \
635       -e "s#$dump_file#DUMP_FILE#"  \
636       -e 's/id:[        ]*[0-9a-f-]*/id: ID/'  \
637       -e 's/time:[      ].*/time: TIME/'       \
638       -e 's/date:[      ].*/date: DATE/'       \
639       -e 's/dump begun .*/dump begun DATE/'    \
640       -e 's/[0-9][0-9]* seconds/SECS seconds/' \
641       -e 's/restore.[0-9][0-9]*/restore.PID/' \
642       -e '/: dump size/s/[1-9][0-9]*/NUM/'     \
643       -e '/dump size:/s/[1-9][0-9]*/NUM/'      \
644       -e '/media file size/s/[1-9][0-9]*/NUM/' \
645       -e '/\/dev\/tty/d' \
646       -e '/inventory session uuid/d' \
647
648 }
649
650 _invutil_filter()
651 {
652   _dump_filter \
653   | sed \
654         -e 's/UUID[     ]*:[    ][0-9a-f-]*/UUID                :       ID/' \
655         -e 's/TIME OF DUMP[     ]*:.*/TIME OF DUMP      :       TIME/' \
656         -e 's/HOSTNAME:SCRATCH_MNT.*/HOSTNAME:SCRATCH_MNT/' \
657         -e 's#inventory/[0-9a-f-]*#inventory/UUID#' \
658
659 }
660
661 _dir_filter()
662 {
663   sed \
664     -e "s#$dump_file#DUMP_FILE#"      \
665     -e "s#$SCRATCH_DEV#SCRATCH_DEV#"        \
666     -e "s#$dumptape#TAPE_DEV#"         \
667     -e "s#$dump_dir#DUMP_DIR#g"       \
668     -e "s#$restore_dir#RESTORE_DIR#g" \
669     -e "s#$SCRATCH_MNT#SCRATCH_MNT#g"       \
670     -e "s#$dump_sdir#DUMP_SUBDIR#g"   \
671     -e "s#$restore_sdir#RESTORE_SUBDIR#g" \
672
673 }
674
675 _parse_args()
676 {
677     OPTIND=0
678     dump_args=""
679     while getopts "f:FL:o" c $*
680     do
681         case $c
682         in
683         f)
684             [ -z "$OPTARG" ] && _error "missing argument for -f"
685             dumptape=$OPTARG    
686             ;;
687         L)
688             [ -z "$OPTARG" ] && _error "missing argument for -L"
689             session_label=$OPTARG       
690             ;;
691         o)
692             dump_args="$dump_args -o"
693             ;;
694         F)
695             dump_args="$dump_args -F"
696             ;;
697         \?)
698             _error "invalid argument"
699             ;;
700         esac
701     done
702 }
703
704
705 #
706 # Dump a subdir
707 #
708 _do_dump_sub()
709 {
710     _parse_args $*
711
712     echo "Dumping to tape..."
713     opts="$_dump_debug$dump_args -s $dump_sdir -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
714     echo "xfsdump $opts" | _dir_filter  
715     xfsdump $opts 2>&1 | tee -a $seq.full | _dump_filter
716 }
717
718 #
719 # Do full level 0 dump
720 #
721 _do_dump()
722 {
723     _parse_args $*
724
725     echo "Dumping to tape..."
726     opts="$_dump_debug$dump_args -l0 -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
727     echo "xfsdump $opts" | _dir_filter  
728     xfsdump $opts 2>&1 | tee -a $seq.full | _dump_filter
729 }
730
731
732 #
733 # Do full dump with -m
734 #
735 _do_dump_min()
736 {
737     _parse_args $*
738
739     echo "Dumping to tape..."
740     onemeg=1048576
741     opts="$_dump_debug$dump_args -m -b $onemeg -l0 -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
742     echo "xfsdump $opts" | _dir_filter  
743     xfsdump $opts 2>&1 | tee -a $seq.full | _dump_filter
744 }
745
746 #
747 # Do level 1 incremental dump
748 #
749 _do_dump_incremental()
750 {
751     _parse_args $*
752
753     echo "Dumping incrementally to tape..."
754     opts="$_dump_debug$dump_args -l1 -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
755     echo "xfsdump $opts" | _dir_filter  
756     xfsdump $opts 2>&1 | tee -a $seq.full | _dump_filter
757 }
758
759 #
760 # Do full dump to file
761 #
762 _do_dump_file()
763 {
764     _parse_args $*
765
766     echo "Dumping to file..."
767     opts="$_dump_debug$dump_args -f $dump_file -M $media_label -L $session_label $SCRATCH_MNT"
768     echo "xfsdump $opts" | _dir_filter  
769     xfsdump $opts 2>&1 | tee -a $seq.full | _dump_filter
770 }
771
772
773 _prepare_restore_dir()
774 {
775     rm -rf $restore_dir
776     if ! mkdir $restore_dir; then
777         echo "    failed to mkdir $restore_dir"
778         status=1
779         exit
780     fi
781 }
782
783
784 #
785 # Get tape ready and restore dir
786 #
787 _prepare_restore()
788 {
789     _prepare_restore_dir
790
791     echo "Rewinding tape"
792     _rewind
793 }
794
795 #
796 # Restore the tape into $restore_dir
797 #
798 _do_restore()
799 {
800     _parse_args $*
801     _prepare_restore
802
803
804     echo "Restoring from tape..."
805     opts="$_restore_debug$dump_args -f $dumptape  -L $session_label $restore_dir"
806     echo "xfsrestore $opts" | _dir_filter  
807     xfsrestore $opts 2>&1 | tee -a $seq.full | _dump_filter
808 }
809
810 #
811 # Restore the tape into $restore_dir using -m
812 #
813 _do_restore_min()
814 {
815     _parse_args $*
816     _prepare_restore
817
818     echo "Restoring from tape..."
819     onemeg=1048576
820     opts="$_restore_debug$dump_args -m -b $onemeg -f $dumptape  -L $session_label $restore_dir"
821     echo "xfsrestore $opts" | _dir_filter  
822     xfsrestore $opts 2>&1 | tee -a $seq.full | _dump_filter
823 }
824
825 #
826 # Restore the tape from a dump file
827 #
828 _do_restore_file()
829 {
830     _parse_args $*
831     _prepare_restore_dir
832
833     echo "Restoring from file..."
834     opts="$_restore_debug$dumpargs -f $dump_file  -L $session_label $restore_dir"
835     echo "xfsrestore $opts" | _dir_filter  
836     xfsrestore $opts 2>&1 | tee -a $seq.full | _dump_filter
837 }
838
839 #
840 # Do xfsdump piped into xfsrestore - xfsdump | xfsrestore
841 #
842 # Use -s as we want to dump and restore to the same xfs partition
843 #
844 _do_dump_restore()
845 {
846     _parse_args $*
847     _prepare_restore_dir
848     echo "xfsdump|xfsrestore ..."
849     restore_opts="$_restore_debug - $restore_dir"
850     dump_opts="$_dump_debug$dump_args -s $dump_sdir - $SCRATCH_MNT"
851     echo "xfsdump $dump_opts | xfsrestore $restore_opts" | _dir_filter  
852     xfsdump $dump_opts 2>$tmp.dump.mlog | xfsrestore $restore_opts 2>&1 | tee -a $seq.full | _dump_filter
853     _dump_filter <$tmp.dump.mlog
854 }
855
856 #
857 # Compare dumped subdirectory with restored dir
858 # using ls -lR.
859 # Thus no contents are compared but permissions, sizes,
860 # owners, etc... are.
861 #
862 _ls_compare_sub()
863 {
864     #
865     # verify we got back what we dumped
866     #
867     echo "Comparing listing of dump directory with restore directory"
868     ls -lR $dump_dir | tee -a $seq.full | _ls_filter >$tmp.dump_dir
869     ls -lR $restore_dir/$dump_sdir | tee -a $seq.full | _ls_filter \
870     | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
871
872     diff -cs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
873 }
874
875
876 #
877 # Compare using recursive diff the files of the dumped
878 # subdirectory.
879 # This one will compare the contents.
880 #
881 _diff_compare_sub()
882 {
883     echo "Comparing dump directory with restore directory"
884     diff -rs $dump_dir $restore_dir/$dump_sdir | _dir_filter
885 }
886
887 #
888 # Compare using recursive diff the files of the dumped
889 # filesystem
890 #
891 _diff_compare()
892 {
893     echo "Comparing dump directory with restore directory"
894     diff -rs $SCRATCH_MNT $restore_dir | _dir_filter
895 }
896
897 #
898 # Check out the dump inventory
899 #
900 _dump_inventory()
901 {
902     xfsdump $_dump_debug -I | tee -a $seq.full | _dump_filter 
903 }
904
905 #
906 # Do the xfsinvutil cmd with debug and filters
907 # Need to set variable: "$middate" to the invutil date 
908 #
909 _do_invutil()
910 {
911     host=`hostname`
912     echo "xfsinvutil $_invutil_debug -M $host:$SCRATCH_MNT \"$middate\" $*" >$seq.full
913     xfsinvutil $_invutil_debug -M $host:$SCRATCH_MNT "$middate" $* \
914     | tee -a $seq.full | _invutil_filter
915 }
916
917 # make sure this script returns success
918 /bin/true