2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. All Rights Reserved.
5 # Functions useful for xfsdump/xfsrestore tests
7 # --- initializations ---
10 if [ -n "$DEBUGDUMP" ]; then
15 # Use dump/restore in qa directory (copy them here) for debugging
16 export PATH="$here:$PATH"
17 export __XFSDUMP_PROG=$(type -P xfsdump)
18 export XFSDUMP_PROG="$__XFSDUMP_PROG -e"
19 export XFSRESTORE_PROG=$(type -P xfsrestore)
20 export XFSINVUTIL_PROG=$(type -P xfsinvutil)
21 [ -x $here/xfsdump ] && echo "Using xfstests' xfsdump for debug"
22 [ -x $here/xfsrestore ] && echo "Using xfstests' xfsrestore for debug"
23 [ -x $here/xfsinvutil ] && echo "Using xfstests' xfsinvutil for debug"
26 [ "$XFSDUMP_PROG" = "" ] && _notrun "xfsdump not found"
27 [ "$XFSRESTORE_PROG" = "" ] && _notrun "xfsrestore not found"
28 [ "$XFSINVUTIL_PROG" = "" ] && _notrun "xfsinvutil not found"
30 # status returned for not run tests
33 # name those directories
34 dump_file=$tmp.dumpfile
35 # dump_file=$here/dumpfile #TEMP OVERRIDE DUMP FILE
37 dump_dir=$SCRATCH_MNT/$dump_sdir
38 restore_sdir=restoredir
39 restore_dir=$SCRATCH_MNT/$restore_sdir
42 media_label="stress_tape_media"
43 session_label="stress_$seq"
45 nobody=4 # define this uid/gid as a number
46 do_quota_check=true # do quota check if quotas enabled
49 trap "_cleanup; exit \$status" 0 1 2 3 15
51 # start inventory from a known base - move it aside for test
52 for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
54 [ -d $dir.$seq ] && rm -rf $dir.$seq
60 [ `uname` = "Linux" ] && have_mtvariable=true
63 _require_multi_stream()
65 $XFSDUMP_PROG -JF -f /dev/null -f /dev/null 2> /dev/null |
66 grep -q "too many -f arguments" &&
67 _notrun "xfsdump multi-stream support required"
70 _require_legacy_v2_format()
73 grep -q "generate format 2 dump" ||
74 _notrun "xfsdump -K option required"
76 $XFSRESTORE_PROG 2>&1 |
77 grep -q "force use of format 2 generation" ||
78 _notrun "xfsrestore -K option required"
82 # do a remote/local mt
89 _rmtdev=`echo $dumptape | $AWK_PROG -F: '{print $2}'`
91 if echo $dumptape | grep '@' >/dev/null; then
92 _spec=`echo $dumptape | $AWK_PROG -F: '{print $1}'`
93 _rmtuser=`echo $_spec | $AWK_PROG -F@ '{print $1}'`
94 _rmthost=`echo $_spec | $AWK_PROG -F@ '{print $2}'`
95 rsh -n -l $_rmtuser $_rmthost "mt -t $_rmtdev $op"
97 _rmthost=`echo $dumptape | $AWK_PROG -F: '{print $1}'`
98 rsh -n $_rmthost "mt -t $_rmtdev $op"
110 while [ $i -lt $_limit ]; do
111 echo "Checking online..." >>$seqres.full
112 if _mt status >$tmp.status 2>&1; then
121 if [ $i -eq $_limit ]; then
122 echo "ERROR: mt -f $dumptape failed"
125 _notrun "mt -f $dumptape failed"
129 if egrep -i 'onl|ready' $tmp.status | grep -iv 'not ready' >/dev/null; then
132 echo "ERROR: $dumptape is not online"
135 _notrun "dumptape, $dumptape, is not online"
141 echo "Wait for tape, $dumptape, ..." >>$seqres.full
144 while [ $i -lt 20 ]; do
145 echo "Checking status..." >>$seqres.full
146 if _mt status 2>&1 | tee -a $seqres.full | egrep -i "onl|ready" >/dev/null; then
156 # Keep trying so we know we really have rewound
160 echo "Initiate rewind..." >>$seqres.full
162 _mt rewind >/dev/null
167 # Do a custom erase because:
168 # (i) some machines don't support it
169 # (ii) some machines take forever to do it
173 echo "Erasing tape" | tee -a $seqres.full
181 echo "Erasing tape" | tee -a $seqres.full
187 echo $dumptape | grep ':' >/dev/null
195 $have_mtvariable || return
201 echo "Put scsi tape driver into variable block size mode"
202 mt -f $dumptape setblk 0
210 if [ -z "$dumptape" -o "@" == "$dumptape" ]; then
211 _notrun "No dump tape specified"
222 _scratch_mkfs_xfs >>$seqres.full || _fail "mkfs failed"
223 _scratch_mount >>$seqres.full
227 # Cleanup created dirs and files
232 # Some tests include this before checking _supported_fs xfs
233 # and the sleeps & checks here get annoying
234 if [ "$FSTYP" != "xfs" ]; then
241 if [ -n "$DEBUGDUMP" ]; then
242 # save it for inspection
243 for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
244 [ -d $dir ] || continue
245 tar -cvf $seqres.inventory.tar $dir
246 ls -nR $dir >$seqres.inventory.ls
250 # put inventory dir back
251 for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
252 [ -d $dir.$seq ] || continue
253 rm -rf $dir # get rid of new one
257 if [ $status -ne $NOTRUNSTS ]; then
258 # Sleep added to stop _check_scratch_fs from complaining that the
259 # scratch_dev is still busy
267 # ensure that bulkstat data will
268 # match with incore data
269 # by forcing disk data to be written out
273 _saveddir=`pwd`; cd /
274 _scratch_unmount >>$seqres.full || _fail "unmount failed"
275 _scratch_mount >>$seqres.full
280 # Run fsstress to create a mixture of
281 # files,dirs,links,symlinks
283 # Pinched from test 013.
284 # Takes one argument, the number of ops to perform
286 _create_dumpdir_stress_num()
288 echo "Creating directory system to dump using fsstress."
293 _param="-f link=10 -f creat=10 -f mkdir=10 -f truncate=5 -f symlink=10"
295 if ! mkdir $dump_dir; then
296 echo " failed to mkdir $dump_dir"
301 # Remove fsstress commands that aren't supported on all xfs configs so that
302 # we always execute exactly the same sequence of operations no matter how
303 # the filesystem is configured
304 if $FSSTRESS_PROG | grep -q clonerange; then
305 FSSTRESS_AVOID="-f clonerange=0 $FSSTRESS_AVOID"
307 if $FSSTRESS_PROG | grep -q deduperange; then
308 FSSTRESS_AVOID="-f deduperange=0 $FSSTRESS_AVOID"
310 if $FSSTRESS_PROG | grep -q copyrange; then
311 FSSTRESS_AVOID="-f copyrange=0 $FSSTRESS_AVOID"
315 echo "-----------------------------------------------"
316 echo "fsstress : $_param"
317 echo "-----------------------------------------------"
318 if ! $here/ltp/fsstress $_param -s 1 $FSSTRESS_AVOID -n $_count -d $dump_dir >$tmp.out 2>&1
320 echo " fsstress (count=$_count) returned $? - see $seqres.full"
322 echo "--------------------------------------" >>$seqres.full
323 echo "output from fsstress:" >>$seqres.full
324 echo "--------------------------------------" >>$seqres.full
325 cat $tmp.out >>$seqres.full
332 _create_dumpdir_stress() {
333 _create_dumpdir_stress_num 240
338 cat <<End-of-File >$tmp.config
339 # pathname size in bytes owner group
341 small 10 $nobody $nobody
342 big 102400 daemon sys
344 sub/big 102400 $nobody sys
346 sub/a 1 $nobody $nobody
347 sub/b 2 $nobody $nobody
348 sub/c 4 $nobody $nobody
349 sub/d 8 $nobody $nobody
350 sub/e 16 $nobody $nobody
351 sub/f 32 $nobody $nobody
352 sub/g 64 $nobody $nobody
353 sub/h 128 $nobody $nobody
354 sub/i 256 $nobody $nobody
355 sub/j 512 $nobody $nobody
356 sub/k 1024 $nobody $nobody
357 sub/l 2048 $nobody $nobody
358 sub/m 4096 $nobody $nobody
359 sub/n 8192 $nobody $nobody
361 sub/a00 100 $nobody $nobody
362 sub/b00 200 $nobody $nobody
363 sub/c00 400 $nobody $nobody
364 sub/d00 800 $nobody $nobody
365 sub/e00 1600 $nobody $nobody
366 sub/f00 3200 $nobody $nobody
367 sub/g00 6400 $nobody $nobody
368 sub/h00 12800 $nobody $nobody
369 sub/i00 25600 $nobody $nobody
370 sub/j00 51200 $nobody $nobody
371 sub/k00 102400 $nobody $nobody
372 sub/l00 204800 $nobody $nobody
373 sub/m00 409600 $nobody $nobody
374 sub/n00 819200 $nobody $nobody
376 sub/a000 1000 $nobody $nobody
377 sub/e000 16000 $nobody $nobody
378 sub/h000 128000 $nobody $nobody
379 sub/k000 1024000 $nobody $nobody
385 cat <<End-of-File >$tmp.config
386 # pathname size in bytes
388 smalll 10 $nobody $nobody
389 biggg 102400 $nobody $nobody
390 sub/smalll 10 $nobody $nobody
391 sub/biggg 102400 $nobody $nobody
395 _mk_fillconfig_perm()
397 cat <<End-of-File >$tmp.config
398 # pathname size/dir user group mode
400 file_suid 10 $nobody $nobody 04777
401 file_guid 10 $nobody $nobody 02777
402 file_sticky 10 $nobody $nobody 01777
403 file_mix1 10 $nobody $nobody 761
404 file_mix2 10 $nobody $nobody 642
405 dir_suid d $nobody $nobody 04777
406 dir_guid d $nobody $nobody 02777
407 dir_sticky d $nobody $nobody 01777
408 dir_mix1 d $nobody $nobody 761
409 dir_mix2 d $nobody $nobody 642
415 cat <<End-of-File >$tmp.config
416 # pathname size user group perm name value namespace
418 smalll 10 $nobody $nobody 777 attr1 some_text user
419 biggg 102400 $nobody $nobody 777 attr2 some_text2 root
420 sub/smalll 10 $nobody $nobody 777 attr3 some_text3 user
421 sub/biggg 102400 $nobody $nobody 777 attr4 some_text4 root
422 dir d $nobody $nobody 777 attr5 dir_text user
424 # Add more files so that there are more than the number
426 # There are bugs in dump/restore for # non-dir files < # streams
427 # It can be tested in another configuration.
428 # It is a pathalogical case.
430 sub/a 1 $nobody $nobody
431 sub/b 2 $nobody $nobody
432 sub/c 4 $nobody $nobody
433 sub/d 8 $nobody $nobody
434 sub/e 16 $nobody $nobody
435 sub/f 32 $nobody $nobody
436 sub/g 64 $nobody $nobody
437 sub/h 128 $nobody $nobody
438 sub/i 256 $nobody $nobody
439 sub/j 512 $nobody $nobody
440 sub/k 1024 $nobody $nobody
441 sub/l 2048 $nobody $nobody
442 sub/m 4096 $nobody $nobody
443 sub/n 8192 $nobody $nobody
448 # extended file attribute flags
450 _mk_fillconfig_xattr()
452 cat <<End-of-File >$tmp.config
453 # pathname size user group perm name
455 xflag_realtime 10 $nobody $nobody 777 XFS_XFLAG_REALTIME
456 xflag_prealloc 10 $nobody $nobody 777 XFS_XFLAG_PREALLOC
457 xflag_immutable 10 $nobody $nobody 777 XFS_XFLAG_IMMUTABLE
458 xflag_append 10 $nobody $nobody 777 XFS_XFLAG_APPEND
459 xflag_sync 10 $nobody $nobody 777 XFS_XFLAG_SYNC
460 xflag_noatime 10 $nobody $nobody 777 XFS_XFLAG_NOATIME
461 xflag_nodump 10 $nobody $nobody 777 XFS_XFLAG_NODUMP
462 xflag_hasattr 10 $nobody $nobody 777 XFS_XFLAG_HASATTR
467 # Create a bunch of directories/files of different sizes
470 # Pinched from test 001.
472 _do_create_dumpdir_fill()
474 echo "Creating directory system to dump using src/fill."
476 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
479 $verbose && echo -n "Setup "
480 sed -e '/^#/d' $tmp.config \
481 | while read file nbytes owner group perms ea_name ea_value namespace
483 if [ $nbytes = "d" ]; then
493 echo "Error: cannot mkdir \"$dir\""
498 # create a directory/file
509 echo "Error: cannot mkdir \"$dir\""
515 if $here/src/fill $file $file $nbytes
520 echo "Error: cannot create \"$file\""
524 if [ -n "$owner" -a -n "$group" ]; then
525 chown $owner.$group $file
527 if [ -n "$perms" ]; then
531 # extended attributes (EA)
532 if [ -n "$ea_name" -a -n "$ea_value" ]; then
533 if [ "X$namespace" = "Xroot" ]; then
534 attr -R -s $ea_name -V $ea_value $file
536 attr -s $ea_name -V $ea_value $file
538 # extended file attribute flags - no value - NOT EAs
539 elif [ -n "$ea_name" -a -z "$ea_value" ]; then
542 # use xfs_io to send the ioctl
545 $verbose && echo -n "."
552 _mk_fillconfig_multi()
555 cat <<End-of-File >>$tmp.config
556 # pathname size in bytes
558 large000 8874368 $nobody $nobody
559 large111 2582912 $nobody $nobody
560 large222 7825792 $nobody $nobody
564 _create_dumpdir_largefile()
567 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
568 _largesize=4294967297
569 _largefile=$dump_dir/largefile
570 echo "dd a largefile at offset $_largesize"
571 POSIXLY_CORRECT=yes \
572 dd if=/dev/zero of=$_largefile bs=1 seek=$_largesize count=10 2>&1
576 _create_dumpdir_fill()
580 _do_create_dumpdir_fill
584 _create_dumpdir_fill2()
588 _do_create_dumpdir_fill
592 _create_dumpdir_fill_perm()
596 _do_create_dumpdir_fill
600 _create_dumpdir_fill_ea()
604 _do_create_dumpdir_fill
609 # Create enough files, and a few large enough files, so that
610 # some files are likely to be split across streams.
612 _create_dumpdir_fill_multi()
616 _do_create_dumpdir_fill
621 # Append a subset of the fill'ed files
622 # So we can see if just these get dumped on an incremental
624 _append_dumpdir_fill()
627 cat <<End-of-File >$tmp.config
637 sed -e '/^#/d' $tmp.config \
640 echo 'Extra text' >>$file
647 _do_create_dump_symlinks()
649 echo "Creating directory system of symlinks to dump."
651 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
654 $verbose && echo -n "Setup "
655 sed -e '/^#/d' $tmp.config \
656 | while read file nbytes owner group owner2 group2 perms perms2
668 echo "Error: cannot mkdir \"$dir\""
676 # Do chmod on symlink using umask.
677 # This won't do the right thing as it subtracts permissions.
678 # However, I don't care, as long as I get some different perms
680 if [ -n "$perms2" ]; then
684 ln -s $file $file-link
685 if [ -n "$perms2" ]; then
689 if [ -n "$owner" -a -n "$group" ]; then
690 chown $owner.$group $file
692 if [ -n "$owner" -a -n "$group" ]; then
693 chown -h $owner.$group $file-link
695 if [ -n "$perms" ]; then
698 $verbose && echo -n "."
707 cat <<End-of-File >$tmp.config
708 # path size owner1 group1 owner2 group2 perm1 perm2
710 a 0 $nobody $nobody daemon sys 124 421
711 b 0 daemon sys bin bin 347 743
712 sub/a 0 bin bin $nobody sys 777 777
713 sub/b 0 $nobody sys $nobody $nobody 367 763
717 _create_dumpdir_symlinks()
721 _do_create_dump_symlinks
726 # create hardlinks of form $_fname, $_fname_h1 $_fname_h2 ...
735 while [ $_j -le $_numlinks ]; do
737 _hardlink=$_fname$_suffix
738 echo "creating hardlink $_hardlink to $_fname"
739 ln $_fname $_hardlink
745 # create a set of hardlinks
746 # create hardlinks of form file1, file1_h1 file1_h2 ...
747 # create hardlinks of form file2, file2_h1 file2_h2 ...
748 # create hardlinks of form file3, file3_h1 file3_h2 ...
754 while [ $_i -le $_numsets ]; do
755 _create_hardlinks file$_i 5
764 echo "mod level $_level" >$dump_dir/file$_level
767 _create_dumpdir_hardlinks()
771 echo "Creating directory system of hardlinks to incrementally dump."
773 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
776 _create_hardset $_numsets
784 # Filter out times and dates on symlinks and char devices.
785 # Filter out size on directories because this can differ
786 # when transitioning to long inode numbers (ie. 64 bits).
791 /^l/ { date = $8; time = $7; sub(date,"DATE"); sub(time,"TIME"); print}
792 /^c/ { date = $9; time = $7; sub(date,"DATE"); sub(time,"TIME"); print}
793 /^d/ { size = $5; sub(size,"SIZE"); print}
795 | sed -e 's/total [0-9][0-9]*/total TOTAL/'
799 # Filtering of Irix character hwgraph device names
801 # chardev: /hw/node/xtalk/15/pci/0/scsi_ctlr/0/target/1/lun/0/disk/partition/4/char
802 # blkdev: /dev/dsk/dks0d1s4
808 sub(/\/hw.*scsi_ctlr\//,"/dev/dsk/dks") # blah blah /dev/dsk/dks0/target/1/....
809 sub(/\/target\//,"d") # blah blah /dev/dsk/dks0d1/lun/0/disk.....
810 sub(/\/lun.*partition\//,"s") # blah blah /dev/dsk/dks0d1s4/char
811 sub(/\/char/,"") # blah blah /dev/dsk/dks0d1s4
819 # Filter out the non-deterministic dump msgs from
820 # xfsdump and xfsrestore
826 -e "s#$__XFSDUMP_PROG#xfsdump#" \
827 -e "s#$XFSRESTORE_PROG#xfsrestore#" \
828 -e "s#$XFSINVUTIL_PROG#xfsinvutil#" \
829 -e "s/`hostname`/HOSTNAME/" \
830 -e "s#$SCRATCH_DEV#SCRATCH_DEV#" \
831 -e "s#$SCRATCH_RAWDEV#SCRATCH_DEV#" \
832 -e "s#$dumptape#TAPE_DEV#" \
833 -e "s#$SCRATCH_MNT#SCRATCH_MNT#" \
834 -e "s#$dump_file#DUMP_FILE#" \
835 -e 's#/var/lib/xfsdump#/var/xfsdump#' \
836 -e 's/session id:[ ]*[0-9a-f-]*/session id: ID/' \
837 -e '/filesystem id:[ ]*[0-9a-f-]*/d' \
838 -e 's/time:[ ].*/time: TIME/' \
839 -e 's/date:[ ].*/date: DATE/' \
840 -e 's/dump begun .*/dump begun DATE/' \
841 -e 's/previously begun .*/previously begun DATE/' \
842 -e 's/[0-9][0-9]* seconds/SECS seconds/' \
843 -e 's/restore.[0-9][0-9]*/restore.PID/' \
844 -e 's/ino [0-9][0-9]*/ino INO/g' \
845 -e '/stream [0-9]:/s/offset [0-9][0-9]*/offset NUM/g' \
846 -e '/: dump size/s/[0-9][0-9]*/NUM/' \
847 -e '/dump size:/s/[0-9][0-9]*/NUM/' \
848 -e '/dump size per stream:/s/[0-9][0-9]*/NUM/' \
849 -e 's/\(media file size[ ]*\)[0-9][0-9]*/\1NUM/' \
850 -e 's/\(mfile size:[ ]*\)[0-9][0-9]*/\1NUM/' \
851 -e '/drive[ ]*[0-9][0-9]*:/d' \
853 -e '/inventory session uuid/d' \
854 -e '/ - Running single-threaded/d' \
855 -e '/Mount point match/d' \
856 -e '/^.*I\/O metrics: .*$/d' \
857 -e 's/1048576/BLOCKSZ/' \
858 -e 's/2097152/BLOCKSZ/' \
859 -e 's/(pid[ ]*[1-9][0-9]*)/\(pid PID\)/' \
860 -e '/version [3-9]\.[0-9]/d' \
861 -e 's/\/hw\/module.*$/SCRATCH_DEV/' \
862 -e 's/xfsdump: ino map phase 1: .*/xfsdump: ino map <PHASES>/' \
863 -e '/xfsdump: ino map phase [2]/,1d' \
864 -e '/xfsdump: ino map phase [3]/,1d' \
865 -e '/xfsdump: ino map phase [4]/,1d' \
866 -e '/xfsdump: ino map phase [5]/,1d' \
867 -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/' \
868 -e 's/\[y\/n\][- ]----------------------*/\[y\/n\]/' \
869 -e '/skip attribute set/d' \
871 # filter out all the output between the lines "Dump Summary:"
873 if ($_ =~ /(?:Dump|Restore) Summary/) {
875 } elsif ($_ =~ /(?:Dump|Restore) Status/) {
878 print if (! $skip);' \
880 # correct the file count if large scratch devices are being used
882 if ($_ =~ /(\S+) directories and (\S+) entries/) {
884 if ($ENV{'LARGE_SCRATCH_DEV'} && $foo > 0) {
887 printf("xfsrestore: %u directories and %u entries processed\n",
898 _dump_filter_main | _check_quota_dumprestore | _check_quota_entries
908 -e 's/UUID[ ]*:[ ][0-9a-f-]*/UUID : ID/' \
909 -e 's/TIME OF DUMP[ ]*:.*/TIME OF DUMP : TIME/' \
910 -e 's/HOSTNAME:SCRATCH_MNT.*/HOSTNAME:SCRATCH_MNT/' \
911 -e 's#inventory/[0-9a-f-]*#inventory/UUID#' \
919 -e "s#$dump_file#DUMP_FILE#g" \
920 -e "s#$SCRATCH_DEV#SCRATCH_DEV#" \
921 -e "s#$SCRATCH_RAWDEV#SCRATCH_DEV#" \
922 -e "s#$dumptape#TAPE_DEV#" \
923 -e "s#$dump_dir#DUMP_DIR#g" \
924 -e "s#$restore_dir#RESTORE_DIR#g" \
925 -e "s#$SCRATCH_MNT#SCRATCH_MNT#g" \
926 -e "s#$dump_sdir#DUMP_SUBDIR#g" \
927 -e "s#$restore_sdir#RESTORE_SUBDIR#g" \
929 -e "/Only in SCRATCH_MNT: .use_space/d" \
930 -e "s#$RESULT_DIR/##g" \
935 # Parse xfsdump arguments.
936 # Note: requires a space between option letter and argument
947 [ -z "$2" ] && _fail "missing argument for -f"
953 [ -z "$2" ] && _fail "missing argument for -L"
958 [ -z "$2" ] && _fail "missing argument for --multi"
969 dump_args="$dump_args $1"
972 [ -z "$2" ] && _fail "missing argument for $1"
973 dump_args="$dump_args $1$2"
977 _fail "invalid argument to common/dump function: $1"
985 # Parse xfsrestore arguments.
986 # Note: requires a space between option letter and argument
988 _parse_restore_args()
997 [ -z "$2" ] && _fail "missing argument for -f"
1003 [ -z "$2" ] && _fail "missing argument for -L"
1008 [ -z "$2" ] && _fail "missing argument for --multi"
1016 do_quota_check=false
1019 restore_args="$restore_args $1"
1022 _fail "invalid argument to common/dump function: $1"
1037 echo "Dumping to tape..."
1038 opts="$_dump_debug$dump_args -s $dump_sdir -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
1039 echo "xfsdump $opts" | _dir_filter
1040 $XFSDUMP_PROG $opts 2>&1 | tee -a $seqres.full | _dump_filter
1050 echo "Dumping to tape..."
1051 opts="$_dump_debug$dump_args -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
1052 echo "xfsdump $opts" | _dir_filter
1053 $XFSDUMP_PROG $opts 2>&1 | tee -a $seqres.full | _dump_filter
1058 # Do full dump with -m
1064 echo "Dumping to tape..."
1066 opts="$_dump_debug$dump_args -m -b $onemeg -l0 -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
1067 echo "xfsdump $opts" | _dir_filter
1068 $XFSDUMP_PROG $opts 2>&1 | tee -a $seqres.full | _dump_filter
1073 # Do full dump to file
1079 echo "Dumping to file..."
1080 opts="$_dump_debug$dump_args -f $dump_file -M $media_label -L $session_label $SCRATCH_MNT"
1081 echo "xfsdump $opts" | _dir_filter
1082 $XFSDUMP_PROG $opts 2>&1 | tee -a $seqres.full | _dump_filter
1086 # Do full dump to multiple files
1088 _do_dump_multi_file()
1095 while [ $i -lt $multi ]
1097 multi_args="$multi_args -f $dump_file.$i -M $media_label.$i"
1101 echo "Dumping to files..."
1102 opts="$_dump_debug$dump_args $multi_args -L $session_label $SCRATCH_MNT"
1103 echo "xfsdump $opts" | _dir_filter
1104 $XFSDUMP_PROG $opts 2>&1 | tee -a $seqres.full | _dump_filter
1108 _prepare_restore_dir()
1111 mkdir $restore_dir || _fail "failed to mkdir $restore_dir"
1116 # Get tape ready and restore dir
1120 _prepare_restore_dir
1122 echo "Rewinding tape"
1127 # Restore the tape into $restore_dir
1131 _parse_restore_args $*
1134 echo "Restoring from tape..."
1135 opts="$_restore_debug$restore_args -f $dumptape -L $session_label $restore_dir"
1136 echo "xfsrestore $opts" | _dir_filter
1137 $XFSRESTORE_PROG $opts 2>&1 | tee -a $seqres.full | _dump_filter
1141 # Restore the tape into $restore_dir using -m
1145 _parse_restore_args $*
1148 echo "Restoring from tape..."
1150 opts="$_restore_debug$restore_args -m -b $onemeg -f $dumptape -L $session_label $restore_dir"
1151 echo "xfsrestore $opts" | _dir_filter
1152 $XFSRESTORE_PROG $opts 2>&1 | tee -a $seqres.full | _dump_filter
1156 # Restore the tape from a dump file
1160 _parse_restore_args $*
1161 _prepare_restore_dir
1163 echo "Restoring from file..."
1164 opts="$_restore_debug$restore_args -f $dump_file -L $session_label $restore_dir"
1165 echo "xfsrestore $opts" | _dir_filter
1166 $XFSRESTORE_PROG $opts 2>&1 | tee -a $seqres.full | _dump_filter
1170 # Cumulative restore from a file
1171 # Must call _prepare_restore_dir before the first
1172 # (and only the first) call to this function.
1174 _do_restore_file_cum()
1176 _parse_restore_args $*
1178 echo "Restoring cumumlative from file..."
1179 opts="$_restore_debug$restore_args -f $dump_file -r $restore_dir"
1180 echo "xfsrestore $opts" | _dir_filter
1181 $XFSRESTORE_PROG $opts 2>&1 | tee -a $seqres.full | _dump_filter
1186 _parse_restore_args $*
1188 echo "Contents of dump ..."
1189 opts="$_restore_debug$restore_args -f $dump_file -t"
1190 echo "xfsrestore $opts" | _dir_filter
1192 $XFSRESTORE_PROG $opts 2>&1 | tee -a $seqres.full | _dump_filter_main |\
1193 _check_quota_file |\
1194 _check_quota_entries |\
1195 $AWK_PROG 'NF != 1 { print; next }
1196 {files = sprintf("%s\n%s", files, $1)}
1197 END { print files | "sort" } '
1198 # the above awk code is to alpha sort only the output
1199 # of files (and not the verbose restore msgs)
1204 # Restore the tape from multiple dump files
1206 _do_restore_multi_file()
1208 _parse_restore_args $*
1209 _prepare_restore_dir
1214 while [ $i -lt $multi ]
1216 multi_args="$multi_args -f $dump_file.$i"
1220 echo "Restoring from file..."
1221 opts="$_restore_debug$restore_args $multi_args -L $session_label $restore_dir"
1222 echo "xfsrestore $opts" | _dir_filter
1223 $XFSRESTORE_PROG $opts 2>&1 | tee -a $seqres.full | _dump_filter
1227 # Do xfsdump piped into xfsrestore - xfsdump | xfsrestore
1228 # Pass dump options in $1 and restore options in $2, if required. e.g.:
1229 # _do_dump_restore "-o -F" "-R"
1230 # _do_dump_restore "" "-R"
1232 # Use -s as we want to dump and restore to the same xfs partition
1237 _parse_restore_args $2
1238 _prepare_restore_dir
1239 echo "xfsdump|xfsrestore ..."
1240 restore_opts="$_restore_debug$restore_args - $restore_dir"
1241 dump_opts="$_dump_debug$dump_args -s $dump_sdir - $SCRATCH_MNT"
1242 echo "xfsdump $dump_opts | xfsrestore $restore_opts" | _dir_filter
1243 $XFSDUMP_PROG $dump_opts 2>$tmp.dump.mlog | $XFSRESTORE_PROG $restore_opts 2>&1 | tee -a $seqres.full | _dump_filter
1244 _dump_filter <$tmp.dump.mlog
1248 # Compare dumped subdirectory with restored dir
1250 # Thus no contents are compared but permissions, sizes,
1251 # owners, etc... are.
1256 # verify we got back what we dumped
1258 echo "Comparing listing of dump directory with restore directory"
1259 ls -nR $dump_dir | tee -a $seqres.full | _ls_filter >$tmp.dump_dir
1260 ls -nR $restore_dir/$dump_sdir | tee -a $seqres.full | _ls_filter \
1261 | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
1263 diff -bcs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
1267 # filter out the date fields
1271 $AWK_PROG 'NF == 9 { print $1, $2, $3, $4, $9 }'
1275 # _ls_compare_sub but don't compare dates
1276 _ls_nodate_compare_sub()
1279 # verify we got back what we dumped
1281 echo "Comparing listing of dump directory with restore directory"
1282 ls -nR $dump_dir | tee -a $seqres.full | _ls_filter | _ls_nodate_filter >$tmp.dump_dir
1283 ls -nR $restore_dir/$dump_sdir | tee -a $seqres.full | _ls_filter \
1284 | _ls_nodate_filter | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
1286 diff -bcs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
1290 # Compare using recursive diff the files of the dumped
1292 # This one will compare the contents.
1296 echo "Comparing dump directory with restore directory"
1297 diff -rs $dump_dir $restore_dir/$dump_sdir | _dir_filter
1304 # Tim - this is the IRIX way...
1305 # find $_path -exec attr -l {} \; |\
1306 # awk '{print $9, $2}' |\
1309 # and this is now the Linux way...
1311 getfattr --absolute-names -Rh -m user $_path |\
1313 if (m/^# file: (\S+)/) { $file = $1 }
1314 elsif (m/^user\.(\w+)/) { print $file, " ",$1,"\n" }' |\
1316 while read file ea_name; do
1317 attr -g $ea_name $file
1320 if [ "$USE_ATTR_SECURE" = yes ]; then
1321 echo "Security names"
1322 getfattr --absolute-names -Rh -m security $_path |\
1324 if (m/^# file: (\S+)/) { $file = $1 }
1325 elsif (m/^security\.(\w+)/) { print $file, " ",$1,"\n" }' |\
1327 while read file ea_name; do
1328 attr -g $ea_name $file
1333 getfattr --absolute-names -Rh -m trusted $_path |\
1335 if (m/^# file: (\S+)/) { $file = $1 }
1336 elsif (m/^trusted\.(\w+)/) { print $file, " ",$1,"\n" }' |\
1338 while read file ea_name; do
1339 attr -R -g $ea_name $file
1344 # Compare the extended attributes of the files/dirs
1345 # b/w the dumped and restore dirs.
1348 # Attribute "attr5" had a 8 byte value for /spare1/dump.5460/dir:
1349 # Attribute "attr5" had a 8 byte value for /spare1/restore.5460/dump.5460/dir:
1353 echo "Comparing dump directory with restore directory"
1354 echo "Looking at the extended attributes (EAs)"
1356 _get_eas_on_path $dump_dir | tee $seqres.ea1 | _dir_filter
1357 echo "EAs on restore"
1358 _get_eas_on_path $restore_dir/$dump_sdir \
1359 | sed -e "s#$restore_sdir\/##" \
1362 diff -s $seqres.ea1 $seqres.ea2 | _dir_filter
1367 # Compare using recursive diff the files of the dumped
1372 echo "Comparing dump directory with restore directory"
1373 diff -rs $SCRATCH_MNT $restore_dir | _dir_filter | _check_quota_diff
1377 # Check out the dump inventory
1381 $XFSDUMP_PROG $_dump_debug -I | tee -a $seqres.full | _dump_filter_main
1385 # Do the xfsinvutil cmd with debug and filters
1386 # Need to set variable: "$middate" to the invutil date
1391 echo "xfsinvutil $_invutil_debug -M $host:$SCRATCH_MNT \"$middate\" $*" >$seqres.full
1392 $XFSINVUTIL_PROG $_invutil_debug $* -M $host:$SCRATCH_MNT "$middate" \
1393 | tee -a $seqres.full | _invutil_filter
1397 # ensure we can find the user quota msg if user quotas are on
1398 # ensure we can find the group quota msg if group quotas are on
1408 $here/src/feature -U $SCRATCH_DEV && uquota=1
1409 $here/src/feature -G $SCRATCH_DEV && gquota=1
1410 $here/src/feature -P $SCRATCH_DEV && pquota=1
1412 $AWK_PROG -v uquota=$uquota -v gquota=$gquota -v pquota=$pquota \
1413 -v full=$seqres.full -v usermsg="$usermsg" \
1414 -v groupmsg="$groupmsg" -v projectmsg="$projectmsg" '
1416 print "Found project quota:", $0 >>full
1419 print "Found extra:", $0
1424 print "Found group quota:", $0 >>full
1427 print "Found extra:", $0
1432 print "Found user quota:", $0 >>full
1435 print "Found extra:", $0
1439 $0 ~ "Restore Status: INCOMPLETE" {
1444 if (uquota && !found_uquota && !incomplete) {
1445 print "Missing user quota msg:", usermsg
1447 if (gquota && !found_gquota && !incomplete) {
1448 print "Missing group quota msg:", groupmsg
1450 if (pquota && !found_pquota && !incomplete) {
1451 print "Missing project quota msg:", projectmsg
1458 # xfsrestore: 3 directories and 40 entries processed
1460 # num entries needs to be reduced by num quota file(s)
1462 _check_quota_entries()
1467 $here/src/feature -U $SCRATCH_DEV && uquota=1
1468 $here/src/feature -G $SCRATCH_DEV && gquota=1
1469 $here/src/feature -P $SCRATCH_DEV && pquota=1
1470 $AWK_PROG -v uquota=$uquota -v gquota=$gquota -v pquota=$pquota '
1471 /entries processed/ {
1481 # xfsdump: saving user quota information for: SCRATCH_MNT
1482 # xfsdump: saving group quota information for: SCRATCH_MNT
1483 # xfsdump: saving project quota information for: SCRATCH_MNT
1484 # xfsrestore: user quota information written to ...'
1485 # xfsrestore: group quota information written to ...'
1486 # xfsrestore: project quota information written to ...'
1487 # xfsrestore: use 'xfs_quota' to restore quotas
1489 _check_quota_dumprestore()
1491 _check_quota 'user quota information' \
1492 'group quota information' \
1493 'project quota information' | \
1494 sed "/xfsrestore:.*use 'xfs_quota' to restore quotas/d"
1499 # Only in RESTORE_DIR: xfsdump_quotas
1500 # Only in RESTORE_DIR: xfsdump_quotas_group
1501 # Only in RESTORE_DIR: xfsdump_quotas_project
1505 _check_quota 'Only in RESTORE_DIR: xfsdump_quotas' \
1506 'Only in RESTORE_DIR: xfsdump_quotas_group' \
1507 'Only in RESTORE_DIR: xfsdump_quotas_proj'
1511 # Look for the quota file in the output
1512 # Ensure that it is there if it should be
1513 # Filter it out so that the output is always the same
1514 # even with no quotas
1518 _check_quota 'xfsdump_quotas' 'xfsdump_quotas_group' 'xfsdump_quotas_proj'
1522 # make sure this script returns success