4 # Functions useful for xfsdump/xfsrestore tests
6 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
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.
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.
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.
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.
27 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
28 # Mountain View, CA 94043, or:
32 # For further information regarding this notice, see:
34 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
37 # --- initializations ---
40 if [ -n "$DEBUGDUMP" ]; then
46 # Use dump/restore in qa directory for debugging
53 # status returned for not run tests
56 # name those directories
57 dump_file=$tmp.dumpfile
58 # dump_file=$here/dumpfile #TEMP OVERRIDE DUMP FILE
60 dump_dir=$SCRATCH_MNT/$dump_sdir
61 restore_sdir=restoredir
62 restore_dir=$SCRATCH_MNT/$restore_sdir
65 media_label="stress_tape_media"
66 session_label="stress_$seq"
68 nobody=4 # define this uid/gid as a number
69 do_quota_check=true # do quota check if quotas enabled
74 trap "_cleanup; exit \$status" 0 1 2 3 15
76 # start inventory from a known base - move it aside for test
77 for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
79 [ -d $dir.$seq ] && rm -rf $dir.$seq
85 [ `uname` = "Linux" ] && have_mtvariable=true
88 # do a remote/local mt
95 _rmtdev=`echo $dumptape | $AWK_PROG -F: '{print $2}'`
97 if echo $dumptape | grep '@' >/dev/null; then
98 _spec=`echo $dumptape | $AWK_PROG -F: '{print $1}'`
99 _rmtuser=`echo $_spec | $AWK_PROG -F@ '{print $1}'`
100 _rmthost=`echo $_spec | $AWK_PROG -F@ '{print $2}'`
101 rsh -n -l $_rmtuser $_rmthost "mt -t $_rmtdev $op"
103 _rmthost=`echo $dumptape | $AWK_PROG -F: '{print $1}'`
104 rsh -n $_rmthost "mt -t $_rmtdev $op"
116 while [ $i -lt $_limit ]; do
117 echo "Checking online..." >>$here/$seq.full
118 if _mt status >$tmp.status 2>&1; then
127 if [ $i -eq $_limit ]; then
128 echo "ERROR: mt -f $dumptape failed"
131 echo "mt -f $dumptape failed" >$seq.notrun
137 if egrep -i 'onl|ready' $tmp.status | grep -iv 'not ready' >/dev/null; then
140 echo "ERROR: $dumptape is not online"
143 echo "dumptape, $dumptape, is not online" >$seq.notrun
151 echo "Wait for tape, $dumptape, ..." >>$here/$seq.full
154 while [ $i -lt 20 ]; do
155 echo "Checking status..." >>$here/$seq.full
156 if _mt status 2>&1 | tee -a $here/$seq.full | egrep -i "onl|ready" >/dev/null; then
166 # Keep trying so we know we really have rewound
170 echo "Initiate rewind..." >>$here/$seq.full
172 _mt rewind >/dev/null
177 # Do a custom erase because:
178 # (i) some machines don't support it
179 # (ii) some machines take forever to do it
183 echo "Erasing tape" | tee -a $here/$seq.full
191 echo "Erasing tape" | tee -a $here/$seq.full
197 echo $dumptape | grep ':' >/dev/null
205 $have_mtvariable || return
211 echo "Put scsi tape driver into variable block size mode"
212 mt -f $dumptape setblk 0
220 if [ -z "$dumptape" ]; then
221 echo "This test requires a dump tape - none was specified"
222 echo "No dump tape specified" >$seq.notrun
235 _scratch_mkfs_xfs >>$here/$seq.full || _fail "mkfs failed"
236 _scratch_mount >>$here/$seq.full || _fail "mount failed"
240 # Cleanup created dirs and files
248 if [ -n "$DEBUGDUMP" ]; then
249 # save it for inspection
250 for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
251 [ -d $dir ] || continue
252 tar -cvf $seq.inventory.tar $dir
253 ls -lR $dir >$seq.inventory.ls
257 # put inventory dir back
258 for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
259 [ -d $dir.$seq ] || continue
260 rm -rf $dir # get rid of new one
264 if [ $status -ne $NOTRUNSTS ]; then
265 # Sleep added to stop _check_scratch_fs from complaining that the
266 # scratch_dev is still busy
274 # ensure that bulkstat data will
275 # match with incore data
276 # by forcing disk data to be written out
280 _saveddir=`pwd`; cd /
281 umount $SCRATCH_MNT >>$here/$seq.full || _fail "unmount failed"
282 _scratch_mount >>$here/$seq.full || _fail "mount failed"
287 # Run fsstress to create a mixture of
288 # files,dirs,links,symlinks
290 # Pinched from test 013.
292 _create_dumpdir_stress()
294 echo "Creating directory system to dump using fsstress."
298 _param="-f link=10 -f creat=10 -f mkdir=10 -f truncate=5 -f symlink=10"
301 if ! mkdir $dump_dir; then
302 echo " failed to mkdir $dump_dir"
307 echo "-----------------------------------------------"
308 echo "fsstress : $_param"
309 echo "-----------------------------------------------"
310 if ! $here/ltp/fsstress $_param -s 1 $FSSTRESS_AVOID -n $_count -d $dump_dir >$tmp.out 2>&1
312 echo " fsstress (count=$_count) returned $? - see $here/$seq.full"
314 echo "--------------------------------------" >>$here/$here/$seq.full
315 echo "output from fsstress:" >>$here/$here/$seq.full
316 echo "--------------------------------------" >>$here/$here/$seq.full
317 cat $tmp.out >>$here/$here/$seq.full
326 cat <<End-of-File >$tmp.config
327 # pathname size in bytes owner group
329 small 10 $nobody $nobody
330 big 102400 daemon sys
332 sub/big 102400 $nobody sys
334 sub/a 1 $nobody $nobody
335 sub/b 2 $nobody $nobody
336 sub/c 4 $nobody $nobody
337 sub/d 8 $nobody $nobody
338 sub/e 16 $nobody $nobody
339 sub/f 32 $nobody $nobody
340 sub/g 64 $nobody $nobody
341 sub/h 128 $nobody $nobody
342 sub/i 256 $nobody $nobody
343 sub/j 512 $nobody $nobody
344 sub/k 1024 $nobody $nobody
345 sub/l 2048 $nobody $nobody
346 sub/m 4096 $nobody $nobody
347 sub/n 8192 $nobody $nobody
349 sub/a00 100 $nobody $nobody
350 sub/b00 200 $nobody $nobody
351 sub/c00 400 $nobody $nobody
352 sub/d00 800 $nobody $nobody
353 sub/e00 1600 $nobody $nobody
354 sub/f00 3200 $nobody $nobody
355 sub/g00 6400 $nobody $nobody
356 sub/h00 12800 $nobody $nobody
357 sub/i00 25600 $nobody $nobody
358 sub/j00 51200 $nobody $nobody
359 sub/k00 102400 $nobody $nobody
360 sub/l00 204800 $nobody $nobody
361 sub/m00 409600 $nobody $nobody
362 sub/n00 819200 $nobody $nobody
364 sub/a000 1000 $nobody $nobody
365 sub/e000 16000 $nobody $nobody
366 sub/h000 128000 $nobody $nobody
367 sub/k000 1024000 $nobody $nobody
373 cat <<End-of-File >$tmp.config
374 # pathname size in bytes
376 smalll 10 $nobody $nobody
377 biggg 102400 $nobody $nobody
378 sub/smalll 10 $nobody $nobody
379 sub/biggg 102400 $nobody $nobody
383 _mk_fillconfig_perm()
385 # dir_guid: ugo=rwx,g+s on dir is for IRIX chmod(1)
387 cat <<End-of-File >$tmp.config
388 # pathname size/dir user group mode
390 file_suid 10 $nobody $nobody 04777
391 file_guid 10 $nobody $nobody 02777
392 file_sticky 10 $nobody $nobody 01777
393 file_mix1 10 $nobody $nobody 761
394 file_mix2 10 $nobody $nobody 642
395 dir_suid d $nobody $nobody 04777
396 dir_guid d $nobody $nobody ugo=rwx,g+s
397 dir_sticky d $nobody $nobody 01777
398 dir_mix1 d $nobody $nobody 761
399 dir_mix2 d $nobody $nobody 642
405 cat <<End-of-File >$tmp.config
406 # pathname size user group perm name value namespace
408 smalll 10 $nobody $nobody 777 attr1 some_text user
409 biggg 102400 $nobody $nobody 777 attr2 some_text2 root
410 sub/smalll 10 $nobody $nobody 777 attr3 some_text3 user
411 sub/biggg 102400 $nobody $nobody 777 attr4 some_text4 root
412 dir d $nobody $nobody 777 attr5 dir_text user
414 # Add more files so that there are more than the number
416 # There are bugs in dump/restore for # non-dir files < # streams
417 # It can be tested in another configuration.
418 # It is a pathalogical case.
420 sub/a 1 $nobody $nobody
421 sub/b 2 $nobody $nobody
422 sub/c 4 $nobody $nobody
423 sub/d 8 $nobody $nobody
424 sub/e 16 $nobody $nobody
425 sub/f 32 $nobody $nobody
426 sub/g 64 $nobody $nobody
427 sub/h 128 $nobody $nobody
428 sub/i 256 $nobody $nobody
429 sub/j 512 $nobody $nobody
430 sub/k 1024 $nobody $nobody
431 sub/l 2048 $nobody $nobody
432 sub/m 4096 $nobody $nobody
433 sub/n 8192 $nobody $nobody
438 # extended file attribute flags
440 _mk_fillconfig_xattr()
442 cat <<End-of-File >$tmp.config
443 # pathname size user group perm name
445 xflag_realtime 10 $nobody $nobody 777 XFS_XFLAG_REALTIME
446 xflag_prealloc 10 $nobody $nobody 777 XFS_XFLAG_PREALLOC
447 xflag_immutable 10 $nobody $nobody 777 XFS_XFLAG_IMMUTABLE
448 xflag_append 10 $nobody $nobody 777 XFS_XFLAG_APPEND
449 xflag_sync 10 $nobody $nobody 777 XFS_XFLAG_SYNC
450 xflag_noatime 10 $nobody $nobody 777 XFS_XFLAG_NOATIME
451 xflag_nodump 10 $nobody $nobody 777 XFS_XFLAG_NODUMP
452 xflag_hasattr 10 $nobody $nobody 777 XFS_XFLAG_HASATTR
457 # Create a bunch of directories/files of different sizes
460 # Pinched from test 001.
462 _do_create_dumpdir_fill()
464 echo "Creating directory system to dump using src/fill."
466 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
469 $verbose && echo -n "Setup "
470 sed -e '/^#/d' $tmp.config \
471 | while read file nbytes owner group perms ea_name ea_value namespace
473 if [ $nbytes = "d" ]; then
483 echo "Error: cannot mkdir \"$dir\""
488 # create a directory/file
499 echo "Error: cannot mkdir \"$dir\""
505 if $here/src/fill $file $file $nbytes
510 echo "Error: cannot create \"$file\""
514 if [ -n "$owner" -a -n "$group" ]; then
515 chown $owner.$group $file
517 if [ -n "$perms" ]; then
521 # extended attributes (EA)
522 if [ -n "$ea_name" -a -n "$ea_value" ]; then
523 if [ "X$namespace" = "Xroot" ]; then
524 attr -R -s $ea_name -V $ea_value $file
526 attr -s $ea_name -V $ea_value $file
528 # extended file attribute flags - no value - NOT EAs
529 elif [ -n "$ea_name" -a -z "$ea_value" ]; then
532 # use xfs_io to send the ioctl
535 $verbose && echo -n "."
542 _create_dumpdir_largefile()
545 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
546 _largesize=4294967297
547 _largefile=$dump_dir/largefile
548 echo "dd a largefile at offset $_largesize"
549 POSIXLY_CORRECT=yes \
550 dd if=/dev/zero of=$_largefile bs=1 seek=$_largesize count=10 2>&1
554 _create_dumpdir_fill()
558 _do_create_dumpdir_fill
562 _create_dumpdir_fill2()
566 _do_create_dumpdir_fill
570 _create_dumpdir_fill_perm()
574 _do_create_dumpdir_fill
578 _create_dumpdir_fill_ea()
582 _do_create_dumpdir_fill
588 # Append a subset of the fill'ed files
589 # So we can see if just these get dumped on an incremental
591 _append_dumpdir_fill()
594 cat <<End-of-File >$tmp.config
604 sed -e '/^#/d' $tmp.config \
607 echo 'Extra text' >>$file
614 _do_create_dump_symlinks()
616 echo "Creating directory system of symlinks to dump."
618 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
621 $verbose && echo -n "Setup "
622 sed -e '/^#/d' $tmp.config \
623 | while read file nbytes owner group owner2 group2 perms perms2
635 echo "Error: cannot mkdir \"$dir\""
643 # Do chmod on symlink using umask.
644 # This won't do the right thing as it subtracts permissions.
645 # However, I don't care, as long as I get some different perms
647 if [ -n "$perms2" ]; then
651 ln -s $file $file-link
652 if [ -n "$perms2" ]; then
656 if [ -n "$owner" -a -n "$group" ]; then
657 chown $owner.$group $file
659 if [ -n "$owner" -a -n "$group" ]; then
660 chown -h $owner.$group $file-link
662 if [ -n "$perms" ]; then
665 $verbose && echo -n "."
674 cat <<End-of-File >$tmp.config
675 # path size owner1 group1 owner2 group2 perm1 perm2
677 a 0 $nobody $nobody daemon sys 124 421
678 b 0 daemon sys bin bin 347 743
679 sub/a 0 bin bin $nobody sys 777 777
680 sub/b 0 $nobody sys $nobody $nobody 367 763
684 _create_dumpdir_symlinks()
688 _do_create_dump_symlinks
693 # create hardlinks of form $_fname, $_fname_h1 $_fname_h2 ...
702 while [ $_j -le $_numlinks ]; do
704 _hardlink=$_fname$_suffix
705 echo "creating hardlink $_hardlink to $_fname"
706 ln $_fname $_hardlink
712 # create a set of hardlinks
713 # create hardlinks of form file1, file1_h1 file1_h2 ...
714 # create hardlinks of form file2, file2_h1 file2_h2 ...
715 # create hardlinks of form file3, file3_h1 file3_h2 ...
721 while [ $_i -le $_numsets ]; do
722 _create_hardlinks file$_i 5
731 echo "mod level $_level" >$dump_dir/file$_level
734 _create_dumpdir_hardlinks()
738 echo "Creating directory system of hardlinks to incrementally dump."
740 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
743 _create_hardset $_numsets
751 # Filter out dates on symlinks and char devices
752 # Filter out size on directories because this can differ
753 # when transitioning to long inode numbers (ie. 64 bits).
758 /^l/ { date = $8; sub(date,"DATE"); print}
759 /^c/ { date = $9; sub(date,"DATE"); print}
760 /^d/ { size = $5; sub(size,"SIZE"); print}
762 | sed -e 's/total [0-9][0-9]*/total TOTAL/'
766 # Filtering of Irix character hwgraph device names
768 # chardev: /hw/node/xtalk/15/pci/0/scsi_ctlr/0/target/1/lun/0/disk/partition/4/char
769 # blkdev: /dev/dsk/dks0d1s4
775 sub(/\/hw.*scsi_ctlr\//,"/dev/dsk/dks") # blah blah /dev/dsk/dks0/target/1/....
776 sub(/\/target\//,"d") # blah blah /dev/dsk/dks0d1/lun/0/disk.....
777 sub(/\/lun.*partition\//,"s") # blah blah /dev/dsk/dks0d1s4/char
778 sub(/\/char/,"") # blah blah /dev/dsk/dks0d1s4
786 # Filter out the non-deterministic dump msgs from
787 # xfsdump and xfsrestore
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/id:[[:space:]]*[0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}/ID: ID/' \
824 -e 's/\[y\/n\][- ]----------------------*/\[y\/n\]/' \
826 if ($_ =~ /(?:Dump|Restore) Summary/) {
828 } elsif ($_ =~ /(?:Dump|Restore) Status/) {
838 _dump_filter_main | _check_quota_dumprestore | _check_quota_entries
848 -e 's/UUID[ ]*:[ ][0-9a-f-]*/UUID : ID/' \
849 -e 's/TIME OF DUMP[ ]*:.*/TIME OF DUMP : TIME/' \
850 -e 's/HOSTNAME:SCRATCH_MNT.*/HOSTNAME:SCRATCH_MNT/' \
851 -e 's#inventory/[0-9a-f-]*#inventory/UUID#' \
859 -e "s#$dump_file#DUMP_FILE#" \
860 -e "s#$SCRATCH_DEV#SCRATCH_DEV#" \
861 -e "s#$SCRATCH_RAWDEV#SCRATCH_DEV#" \
862 -e "s#$dumptape#TAPE_DEV#" \
863 -e "s#$dump_dir#DUMP_DIR#g" \
864 -e "s#$restore_dir#RESTORE_DIR#g" \
865 -e "s#$SCRATCH_MNT#SCRATCH_MNT#g" \
866 -e "s#$dump_sdir#DUMP_SUBDIR#g" \
867 -e "s#$restore_sdir#RESTORE_SUBDIR#g" \
873 # Note: requires a space between option letter and argument
884 [ -z "$2" ] && _fail "missing argument for -f"
889 [ -z "$2" ] && _fail "missing argument for -L"
894 dump_args="$dump_args -o"
897 dump_args="$dump_args -F"
910 [ -z "$2" ] && _fail "missing argument for -l"
911 dump_args="$dump_args -l$2"
915 _fail "invalid argument to common.dump function: $1"
930 echo "Dumping to tape..."
931 opts="$_dump_debug$dump_args -s $dump_sdir -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
932 echo "xfsdump $opts" | _dir_filter
933 xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
943 echo "Dumping to tape..."
944 opts="$_dump_debug$dump_args -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
945 echo "xfsdump $opts" | _dir_filter
946 xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
951 # Do full dump with -m
957 echo "Dumping to tape..."
959 opts="$_dump_debug$dump_args -m -b $onemeg -l0 -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
960 echo "xfsdump $opts" | _dir_filter
961 xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
966 # Do full dump to file
972 echo "Dumping to file..."
973 opts="$_dump_debug$dump_args -f $dump_file -M $media_label -L $session_label $SCRATCH_MNT"
974 echo "xfsdump $opts" | _dir_filter
975 xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
979 # Do full dump to multiple files
981 _do_dump_multi_file()
988 while [ $i -lt $multi ]
990 multi_args="$multi_args -f $dump_file.$i -M $media_label.$i"
994 echo "Dumping to files..."
995 opts="$_dump_debug$dump_args $multi_args -L $session_label $SCRATCH_MNT"
996 echo "xfsdump $opts" | _dir_filter
997 xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1001 _prepare_restore_dir()
1004 mkdir $restore_dir || _fail "failed to mkdir $restore_dir"
1009 # Get tape ready and restore dir
1013 _prepare_restore_dir
1015 echo "Rewinding tape"
1020 # Restore the tape into $restore_dir
1028 echo "Restoring from tape..."
1029 opts="$_restore_debug -f $dumptape -L $session_label $restore_dir"
1030 echo "xfsrestore $opts" | _dir_filter
1031 xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1035 # Restore the tape into $restore_dir using -m
1042 echo "Restoring from tape..."
1044 opts="$_restore_debug -m -b $onemeg -f $dumptape -L $session_label $restore_dir"
1045 echo "xfsrestore $opts" | _dir_filter
1046 xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1050 # Restore the tape from a dump file
1055 _prepare_restore_dir
1057 echo "Restoring from file..."
1058 opts="$_restore_debug -f $dump_file -L $session_label $restore_dir"
1059 echo "xfsrestore $opts" | _dir_filter
1060 xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1064 # Cumulative restore from a file
1065 # Need to specify the dump level e.g. "-l 0"
1067 _do_restore_file_cum()
1070 if echo $dump_args | grep '\-l0' >/dev/null; then
1071 _prepare_restore_dir
1074 echo "Restoring cumumlative from file..."
1075 opts="$_restore_debug -f $dump_file -r $restore_dir"
1076 echo "xfsrestore $opts" | _dir_filter
1077 xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1082 echo "Contents of dump ..."
1083 opts="$_restore_debug -f $dump_file -t"
1084 echo "xfsrestore $opts" | _dir_filter
1085 cd $SCRATCH_MNT # for IRIX which needs xfs cwd
1086 xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter_main |\
1087 _check_quota_file |\
1088 _check_quota_entries |\
1089 $AWK_PROG 'NF != 1 { print; next }
1090 {files = sprintf("%s\n%s", files, $1)}
1091 END { print files | "sort" } '
1092 # the above awk code is to alpha sort only the output
1093 # of files (and not the verbose restore msgs)
1098 # Restore the tape from multiple dump files
1100 _do_restore_multi_file()
1103 _prepare_restore_dir
1108 while [ $i -lt $multi ]
1110 multi_args="$multi_args -f $dump_file.$i"
1114 echo "Restoring from file..."
1115 opts="$_restore_debug $multi_args -L $session_label $restore_dir"
1116 echo "xfsrestore $opts" | _dir_filter
1117 xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1121 # Do xfsdump piped into xfsrestore - xfsdump | xfsrestore
1123 # Use -s as we want to dump and restore to the same xfs partition
1128 _prepare_restore_dir
1129 echo "xfsdump|xfsrestore ..."
1130 restore_opts="$_restore_debug - $restore_dir"
1131 dump_opts="$_dump_debug$dump_args -s $dump_sdir - $SCRATCH_MNT"
1132 echo "xfsdump $dump_opts | xfsrestore $restore_opts" | _dir_filter
1133 xfsdump $dump_opts 2>$tmp.dump.mlog | xfsrestore $restore_opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1134 _dump_filter <$tmp.dump.mlog
1138 # Compare dumped subdirectory with restored dir
1140 # Thus no contents are compared but permissions, sizes,
1141 # owners, etc... are.
1146 # verify we got back what we dumped
1148 echo "Comparing listing of dump directory with restore directory"
1149 ls -lR $dump_dir | tee -a $here/$seq.full | _ls_filter >$tmp.dump_dir
1150 ls -lR $restore_dir/$dump_sdir | tee -a $here/$seq.full | _ls_filter \
1151 | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
1153 diff -cs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
1158 # filter out the date fields
1162 $AWK_PROG 'NF == 9 { print $1, $2, $3, $4, $9 }'
1166 # _ls_compare_sub but don't compare dates
1167 _ls_nodate_compare_sub()
1170 # verify we got back what we dumped
1172 echo "Comparing listing of dump directory with restore directory"
1173 ls -lR $dump_dir | tee -a $here/$seq.full | _ls_filter | _ls_nodate_filter >$tmp.dump_dir
1174 ls -lR $restore_dir/$dump_sdir | tee -a $here/$seq.full | _ls_filter \
1175 | _ls_nodate_filter | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
1177 diff -cs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
1181 # Compare using recursive diff the files of the dumped
1183 # This one will compare the contents.
1187 echo "Comparing dump directory with restore directory"
1188 diff -rs $dump_dir $restore_dir/$dump_sdir | _dir_filter
1195 # Tim - this is the IRIX way...
1196 # find $_path -exec attr -l {} \; |\
1197 # awk '{print $9, $2}' |\
1200 # and this is now the Linux way...
1202 getfattr --absolute-names -Rh -m user $_path |\
1204 if (m/^# file: (\S+)/) { $file = $1 }
1205 elsif (m/^user\.(\w+)/) { print $file, " ",$1,"\n" }' |\
1207 while read file ea_name; do
1208 attr -g $ea_name $file
1211 if [ "$USE_ATTR_SECURE" = yes ]; then
1212 echo "Security names"
1213 getfattr --absolute-names -Rh -m security $_path |\
1215 if (m/^# file: (\S+)/) { $file = $1 }
1216 elsif (m/^security\.(\w+)/) { print $file, " ",$1,"\n" }' |\
1218 while read file ea_name; do
1219 attr -g $ea_name $file
1224 getfattr --absolute-names -Rh -m trusted $_path |\
1226 if (m/^# file: (\S+)/) { $file = $1 }
1227 elsif (m/^trusted\.(\w+)/) { print $file, " ",$1,"\n" }' |\
1229 while read file ea_name; do
1230 attr -R -g $ea_name $file
1235 # Compare the extended attributes of the files/dirs
1236 # b/w the dumped and restore dirs.
1239 # Attribute "attr5" had a 8 byte value for /spare1/dump.5460/dir:
1240 # Attribute "attr5" had a 8 byte value for /spare1/restore.5460/dump.5460/dir:
1244 echo "Comparing dump directory with restore directory"
1245 echo "Looking at the extended attributes (EAs)"
1247 _get_eas_on_path $dump_dir | tee $seq.ea1 | _dir_filter
1248 echo "EAs on restore"
1249 _get_eas_on_path $restore_dir/$dump_sdir \
1250 | sed -e "s#$restore_sdir\/##" \
1253 diff -s $seq.ea1 $seq.ea2
1258 # Compare using recursive diff the files of the dumped
1263 echo "Comparing dump directory with restore directory"
1264 diff -rs $SCRATCH_MNT $restore_dir | _dir_filter | _check_quota_diff
1268 # Check out the dump inventory
1272 xfsdump $_dump_debug -I | tee -a $here/$seq.full | _dump_filter_main
1276 # Do the xfsinvutil cmd with debug and filters
1277 # Need to set variable: "$middate" to the invutil date
1282 echo "xfsinvutil $_invutil_debug -M $host:$SCRATCH_MNT \"$middate\" $*" >$here/$seq.full
1283 xfsinvutil $_invutil_debug $* -M $host:$SCRATCH_MNT "$middate" \
1284 | tee -a $here/$seq.full | _invutil_filter
1288 # ensure we can find the user quota msg if user quotas are on
1289 # ensure we can find the group quota msg if group quotas are on
1297 $here/src/feature -U $SCRATCH_DEV && uquota=1
1298 $here/src/feature -G $SCRATCH_DEV && gquota=1
1300 $AWK_PROG -v uquota=$uquota -v gquota=$gquota -v full=$here/$seq.full \
1301 -v usermsg="$usermsg" -v groupmsg="$groupmsg" '
1303 print "Found group quota:", $0 >>full
1306 print "Found extra:", $0
1311 print "Found user quota:", $0 >>full
1314 print "Found extra:", $0
1320 if (uquota && !found_uquota) {
1321 print "Missing: ", usermsg
1323 if (gquota && !found_gquota) {
1324 print "Missing: ", groupmsg
1331 # xfsrestore: 3 directories and 40 entries processed
1333 # num entries needs to be reduced by num quota file(s)
1335 _check_quota_entries()
1339 $here/src/feature -U $SCRATCH_DEV && uquota=1
1340 $here/src/feature -G $SCRATCH_DEV && gquota=1
1341 $AWK_PROG -v uquota=$uquota -v gquota=$gquota '
1342 /entries processed/ {
1351 # xfsdump: saving user quota information for: SCRATCH_MNT
1352 # xfsdump: saving group quota information for: SCRATCH_MNT
1353 # xfsrestore: user quota information written to ...'
1354 # xfsrestore: group quota information written to ...'
1356 _check_quota_dumprestore()
1358 _check_quota 'user quota information' \
1359 'group quota information'
1364 # Only in RESTORE_DIR: xfsdump_quotas
1365 # Only in RESTORE_DIR: xfsdump_quotas_group
1369 _check_quota 'Only in RESTORE_DIR: xfsdump_quotas' \
1370 'Only in RESTORE_DIR: xfsdump_quotas_group'
1374 # Look for the quota file in the output
1375 # Ensure that it is there if it should be
1376 # Filter it out so that the output is always the same
1377 # even with no quotas
1381 _check_quota 'xfsdump_quotas' 'xfsdump_quotas_group'
1385 # make sure this script returns success