3 # Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. All Rights Reserved.
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation.
9 # This program is distributed in the hope that it would be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write the Free Software Foundation,
16 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 # Functions useful for xfsdump/xfsrestore tests
22 # --- initializations ---
25 if [ -n "$DEBUGDUMP" ]; then
30 # Use dump/restore in qa directory (copy them here) for debugging
31 export PATH="$here:$PATH"
32 export XFSDUMP_PROG="`set_prog_path xfsdump`"
33 export XFSRESTORE_PROG="`set_prog_path xfsrestore`"
34 export XFSINVUTIL_PROG="`set_prog_path xfsinvutil`"
35 [ -x $here/xfsdump ] && echo "Using xfstests' xfsdump for debug"
36 [ -x $here/xfsrestore ] && echo "Using xfstests' xfsrestore for debug"
37 [ -x $here/xfsinvutil ] && echo "Using xfstests' xfsinvutil for debug"
40 [ "$XFSDUMP_PROG" = "" ] && _notrun "xfsdump not found"
41 [ "$XFSRESTORE_PROG" = "" ] && _notrun "xfsrestore not found"
42 [ "$XFSINVUTIL_PROG" = "" ] && _notrun "xfsinvutil not found"
44 # status returned for not run tests
47 # name those directories
48 dump_file=$tmp.dumpfile
49 # dump_file=$here/dumpfile #TEMP OVERRIDE DUMP FILE
51 dump_dir=$SCRATCH_MNT/$dump_sdir
52 restore_sdir=restoredir
53 restore_dir=$SCRATCH_MNT/$restore_sdir
56 media_label="stress_tape_media"
57 session_label="stress_$seq"
59 nobody=4 # define this uid/gid as a number
60 do_quota_check=true # do quota check if quotas enabled
65 trap "_cleanup; exit \$status" 0 1 2 3 15
67 # start inventory from a known base - move it aside for test
68 for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
70 [ -d $dir.$seq ] && rm -rf $dir.$seq
76 [ `uname` = "Linux" ] && have_mtvariable=true
79 # do a remote/local mt
86 _rmtdev=`echo $dumptape | $AWK_PROG -F: '{print $2}'`
88 if echo $dumptape | grep '@' >/dev/null; then
89 _spec=`echo $dumptape | $AWK_PROG -F: '{print $1}'`
90 _rmtuser=`echo $_spec | $AWK_PROG -F@ '{print $1}'`
91 _rmthost=`echo $_spec | $AWK_PROG -F@ '{print $2}'`
92 rsh -n -l $_rmtuser $_rmthost "mt -t $_rmtdev $op"
94 _rmthost=`echo $dumptape | $AWK_PROG -F: '{print $1}'`
95 rsh -n $_rmthost "mt -t $_rmtdev $op"
107 while [ $i -lt $_limit ]; do
108 echo "Checking online..." >>$here/$seq.full
109 if _mt status >$tmp.status 2>&1; then
118 if [ $i -eq $_limit ]; then
119 echo "ERROR: mt -f $dumptape failed"
122 echo "mt -f $dumptape failed" >$seq.notrun
128 if egrep -i 'onl|ready' $tmp.status | grep -iv 'not ready' >/dev/null; then
131 echo "ERROR: $dumptape is not online"
134 echo "dumptape, $dumptape, is not online" >$seq.notrun
142 echo "Wait for tape, $dumptape, ..." >>$here/$seq.full
145 while [ $i -lt 20 ]; do
146 echo "Checking status..." >>$here/$seq.full
147 if _mt status 2>&1 | tee -a $here/$seq.full | egrep -i "onl|ready" >/dev/null; then
157 # Keep trying so we know we really have rewound
161 echo "Initiate rewind..." >>$here/$seq.full
163 _mt rewind >/dev/null
168 # Do a custom erase because:
169 # (i) some machines don't support it
170 # (ii) some machines take forever to do it
174 echo "Erasing tape" | tee -a $here/$seq.full
182 echo "Erasing tape" | tee -a $here/$seq.full
188 echo $dumptape | grep ':' >/dev/null
196 $have_mtvariable || return
202 echo "Put scsi tape driver into variable block size mode"
203 mt -f $dumptape setblk 0
211 if [ -z "$dumptape" -o "@" == "$dumptape" ]; then
212 echo "This test requires a dump tape - none was specified"
213 echo "No dump tape specified" >$seq.notrun
226 _scratch_mkfs_xfs >>$here/$seq.full || _fail "mkfs failed"
227 _scratch_mount >>$here/$seq.full || _fail "mount failed"
231 # Cleanup created dirs and files
236 # Some tests include this before checking _supported_fs xfs
237 # and the sleeps & checks here get annoying
238 if [ "$FSTYP" != "xfs" ]; then
245 if [ -n "$DEBUGDUMP" ]; then
246 # save it for inspection
247 for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
248 [ -d $dir ] || continue
249 tar -cvf $seq.inventory.tar $dir
250 ls -nR $dir >$seq.inventory.ls
254 # put inventory dir back
255 for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
256 [ -d $dir.$seq ] || continue
257 rm -rf $dir # get rid of new one
261 if [ $status -ne $NOTRUNSTS ]; then
262 # Sleep added to stop _check_scratch_fs from complaining that the
263 # scratch_dev is still busy
271 # ensure that bulkstat data will
272 # match with incore data
273 # by forcing disk data to be written out
277 _saveddir=`pwd`; cd /
278 umount $SCRATCH_MNT >>$here/$seq.full || _fail "unmount failed"
279 _scratch_mount >>$here/$seq.full || _fail "mount failed"
284 # Run fsstress to create a mixture of
285 # files,dirs,links,symlinks
287 # Pinched from test 013.
289 _create_dumpdir_stress()
291 echo "Creating directory system to dump using fsstress."
295 _param="-f link=10 -f creat=10 -f mkdir=10 -f truncate=5 -f symlink=10"
298 if ! mkdir $dump_dir; then
299 echo " failed to mkdir $dump_dir"
304 echo "-----------------------------------------------"
305 echo "fsstress : $_param"
306 echo "-----------------------------------------------"
307 if ! $here/ltp/fsstress $_param -s 1 $FSSTRESS_AVOID -n $_count -d $dump_dir >$tmp.out 2>&1
309 echo " fsstress (count=$_count) returned $? - see $here/$seq.full"
311 echo "--------------------------------------" >>$here/$seq.full
312 echo "output from fsstress:" >>$here/$seq.full
313 echo "--------------------------------------" >>$here/$seq.full
314 cat $tmp.out >>$here/$seq.full
323 cat <<End-of-File >$tmp.config
324 # pathname size in bytes owner group
326 small 10 $nobody $nobody
327 big 102400 daemon sys
329 sub/big 102400 $nobody sys
331 sub/a 1 $nobody $nobody
332 sub/b 2 $nobody $nobody
333 sub/c 4 $nobody $nobody
334 sub/d 8 $nobody $nobody
335 sub/e 16 $nobody $nobody
336 sub/f 32 $nobody $nobody
337 sub/g 64 $nobody $nobody
338 sub/h 128 $nobody $nobody
339 sub/i 256 $nobody $nobody
340 sub/j 512 $nobody $nobody
341 sub/k 1024 $nobody $nobody
342 sub/l 2048 $nobody $nobody
343 sub/m 4096 $nobody $nobody
344 sub/n 8192 $nobody $nobody
346 sub/a00 100 $nobody $nobody
347 sub/b00 200 $nobody $nobody
348 sub/c00 400 $nobody $nobody
349 sub/d00 800 $nobody $nobody
350 sub/e00 1600 $nobody $nobody
351 sub/f00 3200 $nobody $nobody
352 sub/g00 6400 $nobody $nobody
353 sub/h00 12800 $nobody $nobody
354 sub/i00 25600 $nobody $nobody
355 sub/j00 51200 $nobody $nobody
356 sub/k00 102400 $nobody $nobody
357 sub/l00 204800 $nobody $nobody
358 sub/m00 409600 $nobody $nobody
359 sub/n00 819200 $nobody $nobody
361 sub/a000 1000 $nobody $nobody
362 sub/e000 16000 $nobody $nobody
363 sub/h000 128000 $nobody $nobody
364 sub/k000 1024000 $nobody $nobody
370 cat <<End-of-File >$tmp.config
371 # pathname size in bytes
373 smalll 10 $nobody $nobody
374 biggg 102400 $nobody $nobody
375 sub/smalll 10 $nobody $nobody
376 sub/biggg 102400 $nobody $nobody
380 _mk_fillconfig_perm()
382 # dir_guid: ugo=rwx,g+s on dir is for IRIX chmod(1)
384 cat <<End-of-File >$tmp.config
385 # pathname size/dir user group mode
387 file_suid 10 $nobody $nobody 04777
388 file_guid 10 $nobody $nobody 02777
389 file_sticky 10 $nobody $nobody 01777
390 file_mix1 10 $nobody $nobody 761
391 file_mix2 10 $nobody $nobody 642
392 dir_suid d $nobody $nobody 04777
393 dir_guid d $nobody $nobody ugo=rwx,g+s
394 dir_sticky d $nobody $nobody 01777
395 dir_mix1 d $nobody $nobody 761
396 dir_mix2 d $nobody $nobody 642
402 cat <<End-of-File >$tmp.config
403 # pathname size user group perm name value namespace
405 smalll 10 $nobody $nobody 777 attr1 some_text user
406 biggg 102400 $nobody $nobody 777 attr2 some_text2 root
407 sub/smalll 10 $nobody $nobody 777 attr3 some_text3 user
408 sub/biggg 102400 $nobody $nobody 777 attr4 some_text4 root
409 dir d $nobody $nobody 777 attr5 dir_text user
411 # Add more files so that there are more than the number
413 # There are bugs in dump/restore for # non-dir files < # streams
414 # It can be tested in another configuration.
415 # It is a pathalogical case.
417 sub/a 1 $nobody $nobody
418 sub/b 2 $nobody $nobody
419 sub/c 4 $nobody $nobody
420 sub/d 8 $nobody $nobody
421 sub/e 16 $nobody $nobody
422 sub/f 32 $nobody $nobody
423 sub/g 64 $nobody $nobody
424 sub/h 128 $nobody $nobody
425 sub/i 256 $nobody $nobody
426 sub/j 512 $nobody $nobody
427 sub/k 1024 $nobody $nobody
428 sub/l 2048 $nobody $nobody
429 sub/m 4096 $nobody $nobody
430 sub/n 8192 $nobody $nobody
435 # extended file attribute flags
437 _mk_fillconfig_xattr()
439 cat <<End-of-File >$tmp.config
440 # pathname size user group perm name
442 xflag_realtime 10 $nobody $nobody 777 XFS_XFLAG_REALTIME
443 xflag_prealloc 10 $nobody $nobody 777 XFS_XFLAG_PREALLOC
444 xflag_immutable 10 $nobody $nobody 777 XFS_XFLAG_IMMUTABLE
445 xflag_append 10 $nobody $nobody 777 XFS_XFLAG_APPEND
446 xflag_sync 10 $nobody $nobody 777 XFS_XFLAG_SYNC
447 xflag_noatime 10 $nobody $nobody 777 XFS_XFLAG_NOATIME
448 xflag_nodump 10 $nobody $nobody 777 XFS_XFLAG_NODUMP
449 xflag_hasattr 10 $nobody $nobody 777 XFS_XFLAG_HASATTR
454 # Create a bunch of directories/files of different sizes
457 # Pinched from test 001.
459 _do_create_dumpdir_fill()
461 echo "Creating directory system to dump using src/fill."
463 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
466 $verbose && echo -n "Setup "
467 sed -e '/^#/d' $tmp.config \
468 | while read file nbytes owner group perms ea_name ea_value namespace
470 if [ $nbytes = "d" ]; then
480 echo "Error: cannot mkdir \"$dir\""
485 # create a directory/file
496 echo "Error: cannot mkdir \"$dir\""
502 if $here/src/fill $file $file $nbytes
507 echo "Error: cannot create \"$file\""
511 if [ -n "$owner" -a -n "$group" ]; then
512 chown $owner.$group $file
514 if [ -n "$perms" ]; then
518 # extended attributes (EA)
519 if [ -n "$ea_name" -a -n "$ea_value" ]; then
520 if [ "X$namespace" = "Xroot" ]; then
521 attr -R -s $ea_name -V $ea_value $file
523 attr -s $ea_name -V $ea_value $file
525 # extended file attribute flags - no value - NOT EAs
526 elif [ -n "$ea_name" -a -z "$ea_value" ]; then
529 # use xfs_io to send the ioctl
532 $verbose && echo -n "."
539 _create_dumpdir_largefile()
542 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
543 _largesize=4294967297
544 _largefile=$dump_dir/largefile
545 echo "dd a largefile at offset $_largesize"
546 POSIXLY_CORRECT=yes \
547 dd if=/dev/zero of=$_largefile bs=1 seek=$_largesize count=10 2>&1
551 _create_dumpdir_fill()
555 _do_create_dumpdir_fill
559 _create_dumpdir_fill2()
563 _do_create_dumpdir_fill
567 _create_dumpdir_fill_perm()
571 _do_create_dumpdir_fill
575 _create_dumpdir_fill_ea()
579 _do_create_dumpdir_fill
585 # Append a subset of the fill'ed files
586 # So we can see if just these get dumped on an incremental
588 _append_dumpdir_fill()
591 cat <<End-of-File >$tmp.config
601 sed -e '/^#/d' $tmp.config \
604 echo 'Extra text' >>$file
611 _do_create_dump_symlinks()
613 echo "Creating directory system of symlinks to dump."
615 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
618 $verbose && echo -n "Setup "
619 sed -e '/^#/d' $tmp.config \
620 | while read file nbytes owner group owner2 group2 perms perms2
632 echo "Error: cannot mkdir \"$dir\""
640 # Do chmod on symlink using umask.
641 # This won't do the right thing as it subtracts permissions.
642 # However, I don't care, as long as I get some different perms
644 if [ -n "$perms2" ]; then
648 ln -s $file $file-link
649 if [ -n "$perms2" ]; then
653 if [ -n "$owner" -a -n "$group" ]; then
654 chown $owner.$group $file
656 if [ -n "$owner" -a -n "$group" ]; then
657 chown -h $owner.$group $file-link
659 if [ -n "$perms" ]; then
662 $verbose && echo -n "."
671 cat <<End-of-File >$tmp.config
672 # path size owner1 group1 owner2 group2 perm1 perm2
674 a 0 $nobody $nobody daemon sys 124 421
675 b 0 daemon sys bin bin 347 743
676 sub/a 0 bin bin $nobody sys 777 777
677 sub/b 0 $nobody sys $nobody $nobody 367 763
681 _create_dumpdir_symlinks()
685 _do_create_dump_symlinks
690 # create hardlinks of form $_fname, $_fname_h1 $_fname_h2 ...
699 while [ $_j -le $_numlinks ]; do
701 _hardlink=$_fname$_suffix
702 echo "creating hardlink $_hardlink to $_fname"
703 ln $_fname $_hardlink
709 # create a set of hardlinks
710 # create hardlinks of form file1, file1_h1 file1_h2 ...
711 # create hardlinks of form file2, file2_h1 file2_h2 ...
712 # create hardlinks of form file3, file3_h1 file3_h2 ...
718 while [ $_i -le $_numsets ]; do
719 _create_hardlinks file$_i 5
728 echo "mod level $_level" >$dump_dir/file$_level
731 _create_dumpdir_hardlinks()
735 echo "Creating directory system of hardlinks to incrementally dump."
737 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
740 _create_hardset $_numsets
748 # Filter out times and dates on symlinks and char devices.
749 # Filter out size on directories because this can differ
750 # when transitioning to long inode numbers (ie. 64 bits).
755 /^l/ { date = $8; time = $7; sub(date,"DATE"); sub(time,"TIME"); print}
756 /^c/ { date = $9; time = $7; sub(date,"DATE"); sub(time,"TIME"); print}
757 /^d/ { size = $5; sub(size,"SIZE"); print}
759 | sed -e 's/total [0-9][0-9]*/total TOTAL/'
763 # Filtering of Irix character hwgraph device names
765 # chardev: /hw/node/xtalk/15/pci/0/scsi_ctlr/0/target/1/lun/0/disk/partition/4/char
766 # blkdev: /dev/dsk/dks0d1s4
772 sub(/\/hw.*scsi_ctlr\//,"/dev/dsk/dks") # blah blah /dev/dsk/dks0/target/1/....
773 sub(/\/target\//,"d") # blah blah /dev/dsk/dks0d1/lun/0/disk.....
774 sub(/\/lun.*partition\//,"s") # blah blah /dev/dsk/dks0d1s4/char
775 sub(/\/char/,"") # blah blah /dev/dsk/dks0d1s4
783 # Filter out the non-deterministic dump msgs from
784 # xfsdump and xfsrestore
790 -e "s#$XFSDUMP_PROG#xfsdump#" \
791 -e "s#$XFSRESTORE_PROG#xfsrestore#" \
792 -e "s#$XFSINVUTIL_PROG#xfsinvutil#" \
793 -e "s/`hostname`/HOSTNAME/" \
794 -e "s#$SCRATCH_DEV#SCRATCH_DEV#" \
795 -e "s#$SCRATCH_RAWDEV#SCRATCH_DEV#" \
796 -e "s#$dumptape#TAPE_DEV#" \
797 -e "s#$SCRATCH_MNT#SCRATCH_MNT#" \
798 -e "s#$dump_file#DUMP_FILE#" \
799 -e 's#/var/lib/xfsdump#/var/xfsdump#' \
800 -e 's/session id:[ ]*[0-9a-f-]*/session id: ID/' \
801 -e '/filesystem id:[ ]*[0-9a-f-]*/d' \
802 -e 's/time:[ ].*/time: TIME/' \
803 -e 's/date:[ ].*/date: DATE/' \
804 -e 's/dump begun .*/dump begun DATE/' \
805 -e 's/[0-9][0-9]* seconds/SECS seconds/' \
806 -e 's/restore.[0-9][0-9]*/restore.PID/' \
807 -e 's/ino [0-9][0-9]*/ino INO/' \
808 -e '/: dump size/s/[0-9][0-9]*/NUM/' \
809 -e '/dump size:/s/[0-9][0-9]*/NUM/' \
810 -e '/dump size per stream:/s/[0-9][0-9]*/NUM/' \
811 -e 's/\(media file size[ ]*\)[0-9][0-9]*/\1NUM/' \
812 -e 's/\(mfile size:[ ]*\)[0-9][0-9]*/\1NUM/' \
813 -e '/drive[ ]*[0-9][0-9]*:/d' \
815 -e '/inventory session uuid/d' \
816 -e '/ - Running single-threaded/d' \
817 -e '/^.*I\/O metrics: .*$/d' \
818 -e 's/1048576/BLOCKSZ/' \
819 -e 's/2097152/BLOCKSZ/' \
820 -e 's/(pid[ ]*[1-9][0-9]*)/\(pid PID\)/' \
821 -e '/version 3\.0/d' \
822 -e 's/\/hw\/module.*$/SCRATCH_DEV/' \
823 -e 's/xfsdump: ino map phase 1: .*/xfsdump: ino map <PHASES>/' \
824 -e '/xfsdump: ino map phase [2]/,1d' \
825 -e '/xfsdump: ino map phase [3]/,1d' \
826 -e '/xfsdump: ino map phase [4]/,1d' \
827 -e '/xfsdump: ino map phase [5]/,1d' \
828 -e 's/id:[[:space:]]*[0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}/ID: ID/' \
829 -e 's/\[y\/n\][- ]----------------------*/\[y\/n\]/' \
831 if ($_ =~ /(?:Dump|Restore) Summary/) {
833 } elsif ($_ =~ /(?:Dump|Restore) Status/) {
843 _dump_filter_main | _check_quota_dumprestore | _check_quota_entries
853 -e 's/UUID[ ]*:[ ][0-9a-f-]*/UUID : ID/' \
854 -e 's/TIME OF DUMP[ ]*:.*/TIME OF DUMP : TIME/' \
855 -e 's/HOSTNAME:SCRATCH_MNT.*/HOSTNAME:SCRATCH_MNT/' \
856 -e 's#inventory/[0-9a-f-]*#inventory/UUID#' \
864 -e "s#$dump_file#DUMP_FILE#" \
865 -e "s#$SCRATCH_DEV#SCRATCH_DEV#" \
866 -e "s#$SCRATCH_RAWDEV#SCRATCH_DEV#" \
867 -e "s#$dumptape#TAPE_DEV#" \
868 -e "s#$dump_dir#DUMP_DIR#g" \
869 -e "s#$restore_dir#RESTORE_DIR#g" \
870 -e "s#$SCRATCH_MNT#SCRATCH_MNT#g" \
871 -e "s#$dump_sdir#DUMP_SUBDIR#g" \
872 -e "s#$restore_sdir#RESTORE_SUBDIR#g" \
878 # Note: requires a space between option letter and argument
889 [ -z "$2" ] && _fail "missing argument for -f"
894 [ -z "$2" ] && _fail "missing argument for -L"
899 dump_args="$dump_args -o"
902 dump_args="$dump_args -F"
915 [ -z "$2" ] && _fail "missing argument for -l"
916 dump_args="$dump_args -l$2"
920 _fail "invalid argument to common.dump function: $1"
935 echo "Dumping to tape..."
936 opts="$_dump_debug$dump_args -s $dump_sdir -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
937 echo "xfsdump $opts" | _dir_filter
938 $XFSDUMP_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
948 echo "Dumping to tape..."
949 opts="$_dump_debug$dump_args -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
950 echo "xfsdump $opts" | _dir_filter
951 $XFSDUMP_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
956 # Do full dump with -m
962 echo "Dumping to tape..."
964 opts="$_dump_debug$dump_args -m -b $onemeg -l0 -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
965 echo "xfsdump $opts" | _dir_filter
966 $XFSDUMP_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
971 # Do full dump to file
977 echo "Dumping to file..."
978 opts="$_dump_debug$dump_args -f $dump_file -M $media_label -L $session_label $SCRATCH_MNT"
979 echo "xfsdump $opts" | _dir_filter
980 $XFSDUMP_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
984 # Do full dump to multiple files
986 _do_dump_multi_file()
993 while [ $i -lt $multi ]
995 multi_args="$multi_args -f $dump_file.$i -M $media_label.$i"
999 echo "Dumping to files..."
1000 opts="$_dump_debug$dump_args $multi_args -L $session_label $SCRATCH_MNT"
1001 echo "xfsdump $opts" | _dir_filter
1002 $XFSDUMP_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1006 _prepare_restore_dir()
1009 mkdir $restore_dir || _fail "failed to mkdir $restore_dir"
1014 # Get tape ready and restore dir
1018 _prepare_restore_dir
1020 echo "Rewinding tape"
1025 # Restore the tape into $restore_dir
1033 echo "Restoring from tape..."
1034 opts="$_restore_debug -f $dumptape -L $session_label $restore_dir"
1035 echo "xfsrestore $opts" | _dir_filter
1036 $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1040 # Restore the tape into $restore_dir using -m
1047 echo "Restoring from tape..."
1049 opts="$_restore_debug -m -b $onemeg -f $dumptape -L $session_label $restore_dir"
1050 echo "xfsrestore $opts" | _dir_filter
1051 $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1055 # Restore the tape from a dump file
1060 _prepare_restore_dir
1062 echo "Restoring from file..."
1063 opts="$_restore_debug -f $dump_file -L $session_label $restore_dir"
1064 echo "xfsrestore $opts" | _dir_filter
1065 $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1069 # Cumulative restore from a file
1070 # Need to specify the dump level e.g. "-l 0"
1072 _do_restore_file_cum()
1075 if echo $dump_args | grep '\-l0' >/dev/null; then
1076 _prepare_restore_dir
1079 echo "Restoring cumumlative from file..."
1080 opts="$_restore_debug -f $dump_file -r $restore_dir"
1081 echo "xfsrestore $opts" | _dir_filter
1082 $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1087 echo "Contents of dump ..."
1088 opts="$_restore_debug -f $dump_file -t"
1089 echo "xfsrestore $opts" | _dir_filter
1090 cd $SCRATCH_MNT # for IRIX which needs xfs cwd
1091 $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter_main |\
1092 _check_quota_file |\
1093 _check_quota_entries |\
1094 $AWK_PROG 'NF != 1 { print; next }
1095 {files = sprintf("%s\n%s", files, $1)}
1096 END { print files | "sort" } '
1097 # the above awk code is to alpha sort only the output
1098 # of files (and not the verbose restore msgs)
1103 # Restore the tape from multiple dump files
1105 _do_restore_multi_file()
1108 _prepare_restore_dir
1113 while [ $i -lt $multi ]
1115 multi_args="$multi_args -f $dump_file.$i"
1119 echo "Restoring from file..."
1120 opts="$_restore_debug $multi_args -L $session_label $restore_dir"
1121 echo "xfsrestore $opts" | _dir_filter
1122 $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1126 # Do xfsdump piped into xfsrestore - xfsdump | xfsrestore
1128 # Use -s as we want to dump and restore to the same xfs partition
1133 _prepare_restore_dir
1134 echo "xfsdump|xfsrestore ..."
1135 restore_opts="$_restore_debug - $restore_dir"
1136 dump_opts="$_dump_debug$dump_args -s $dump_sdir - $SCRATCH_MNT"
1137 echo "xfsdump $dump_opts | xfsrestore $restore_opts" | _dir_filter
1138 $XFSDUMP_PROG $dump_opts 2>$tmp.dump.mlog | $XFSRESTORE_PROG $restore_opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1139 _dump_filter <$tmp.dump.mlog
1143 # Compare dumped subdirectory with restored dir
1145 # Thus no contents are compared but permissions, sizes,
1146 # owners, etc... are.
1151 # verify we got back what we dumped
1153 echo "Comparing listing of dump directory with restore directory"
1154 ls -nR $dump_dir | tee -a $here/$seq.full | _ls_filter >$tmp.dump_dir
1155 ls -nR $restore_dir/$dump_sdir | tee -a $here/$seq.full | _ls_filter \
1156 | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
1158 diff -bcs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
1162 # filter out the date fields
1166 $AWK_PROG 'NF == 9 { print $1, $2, $3, $4, $9 }'
1170 # _ls_compare_sub but don't compare dates
1171 _ls_nodate_compare_sub()
1174 # verify we got back what we dumped
1176 echo "Comparing listing of dump directory with restore directory"
1177 ls -nR $dump_dir | tee -a $here/$seq.full | _ls_filter | _ls_nodate_filter >$tmp.dump_dir
1178 ls -nR $restore_dir/$dump_sdir | tee -a $here/$seq.full | _ls_filter \
1179 | _ls_nodate_filter | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
1181 diff -bcs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
1185 # Compare using recursive diff the files of the dumped
1187 # This one will compare the contents.
1191 echo "Comparing dump directory with restore directory"
1192 diff -rs $dump_dir $restore_dir/$dump_sdir | _dir_filter
1199 # Tim - this is the IRIX way...
1200 # find $_path -exec attr -l {} \; |\
1201 # awk '{print $9, $2}' |\
1204 # and this is now the Linux way...
1206 getfattr --absolute-names -Rh -m user $_path |\
1208 if (m/^# file: (\S+)/) { $file = $1 }
1209 elsif (m/^user\.(\w+)/) { print $file, " ",$1,"\n" }' |\
1211 while read file ea_name; do
1212 attr -g $ea_name $file
1215 if [ "$USE_ATTR_SECURE" = yes ]; then
1216 echo "Security names"
1217 getfattr --absolute-names -Rh -m security $_path |\
1219 if (m/^# file: (\S+)/) { $file = $1 }
1220 elsif (m/^security\.(\w+)/) { print $file, " ",$1,"\n" }' |\
1222 while read file ea_name; do
1223 attr -g $ea_name $file
1228 getfattr --absolute-names -Rh -m trusted $_path |\
1230 if (m/^# file: (\S+)/) { $file = $1 }
1231 elsif (m/^trusted\.(\w+)/) { print $file, " ",$1,"\n" }' |\
1233 while read file ea_name; do
1234 attr -R -g $ea_name $file
1239 # Compare the extended attributes of the files/dirs
1240 # b/w the dumped and restore dirs.
1243 # Attribute "attr5" had a 8 byte value for /spare1/dump.5460/dir:
1244 # Attribute "attr5" had a 8 byte value for /spare1/restore.5460/dump.5460/dir:
1248 echo "Comparing dump directory with restore directory"
1249 echo "Looking at the extended attributes (EAs)"
1251 _get_eas_on_path $dump_dir | tee $seq.ea1 | _dir_filter
1252 echo "EAs on restore"
1253 _get_eas_on_path $restore_dir/$dump_sdir \
1254 | sed -e "s#$restore_sdir\/##" \
1257 diff -s $seq.ea1 $seq.ea2
1262 # Compare using recursive diff the files of the dumped
1267 echo "Comparing dump directory with restore directory"
1268 diff -rs $SCRATCH_MNT $restore_dir | _dir_filter | _check_quota_diff
1272 # Check out the dump inventory
1276 $XFSDUMP_PROG $_dump_debug -I | tee -a $here/$seq.full | _dump_filter_main
1280 # Do the xfsinvutil cmd with debug and filters
1281 # Need to set variable: "$middate" to the invutil date
1286 echo "xfsinvutil $_invutil_debug -M $host:$SCRATCH_MNT \"$middate\" $*" >$here/$seq.full
1287 $XFSINVUTIL_PROG $_invutil_debug $* -M $host:$SCRATCH_MNT "$middate" \
1288 | tee -a $here/$seq.full | _invutil_filter
1292 # ensure we can find the user quota msg if user quotas are on
1293 # ensure we can find the group quota msg if group quotas are on
1303 $here/src/feature -U $SCRATCH_DEV && uquota=1
1304 $here/src/feature -G $SCRATCH_DEV && gquota=1
1305 $here/src/feature -P $SCRATCH_DEV && pquota=1
1307 $AWK_PROG -v uquota=$uquota -v gquota=$gquota -v pquota=$pquota \
1308 -v full=$here/$seq.full -v usermsg="$usermsg" \
1309 -v groupmsg="$groupmsg" -v projectmsg="$projectmsg" '
1311 print "Found project quota:", $0 >>full
1314 print "Found extra:", $0
1319 print "Found group quota:", $0 >>full
1322 print "Found extra:", $0
1327 print "Found user quota:", $0 >>full
1330 print "Found extra:", $0
1336 if (uquota && !found_uquota) {
1337 print "Missing user quota msg:", usermsg
1339 if (gquota && !found_gquota) {
1340 print "Missing group quota msg:", groupmsg
1342 if (pquota && !found_pquota) {
1343 print "Missing project quota msg:", projectmsg
1350 # xfsrestore: 3 directories and 40 entries processed
1352 # num entries needs to be reduced by num quota file(s)
1354 _check_quota_entries()
1359 $here/src/feature -U $SCRATCH_DEV && uquota=1
1360 $here/src/feature -G $SCRATCH_DEV && gquota=1
1361 $here/src/feature -P $SCRATCH_DEV && pquota=1
1362 $AWK_PROG -v uquota=$uquota -v gquota=$gquota -v pquota=$pquota '
1363 /entries processed/ {
1373 # xfsdump: saving user quota information for: SCRATCH_MNT
1374 # xfsdump: saving group quota information for: SCRATCH_MNT
1375 # xfsdump: saving project quota information for: SCRATCH_MNT
1376 # xfsrestore: user quota information written to ...'
1377 # xfsrestore: group quota information written to ...'
1378 # xfsrestore: project quota information written to ...'
1380 # If on IRIX then look for:
1381 # xfsrestore: use 'edquota' to restore quotas
1383 # xfsrestore: use 'xfs_quota' to restore quotas
1385 _check_quota_dumprestore()
1387 if [ "$HOSTOS" == "IRIX" ]; then
1388 _check_quota 'user quota information' \
1389 'group quota information' \
1390 'project quota information' | \
1391 sed "/xfsrestore:.*use 'edquota' to restore quotas/d"
1393 _check_quota 'user quota information' \
1394 'group quota information' \
1395 'project quota information' | \
1396 sed "/xfsrestore:.*use 'xfs_quota' to restore quotas/d"
1402 # Only in RESTORE_DIR: xfsdump_quotas
1403 # Only in RESTORE_DIR: xfsdump_quotas_group
1404 # Only in RESTORE_DIR: xfsdump_quotas_project
1408 _check_quota 'Only in RESTORE_DIR: xfsdump_quotas' \
1409 'Only in RESTORE_DIR: xfsdump_quotas_group' \
1410 'Only in RESTORE_DIR: xfsdump_quotas_proj'
1414 # Look for the quota file in the output
1415 # Ensure that it is there if it should be
1416 # Filter it out so that the output is always the same
1417 # even with no quotas
1421 _check_quota 'xfsdump_quotas' 'xfsdump_quotas_group' 'xfsdump_quotas_proj'
1425 # make sure this script returns success