3 # Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. All Rights Reserved.
5 # Functions useful for xfsdump/xfsrestore tests
8 # --- initializations ---
11 if [ -n "$DEBUGDUMP" ]; then
16 # Use dump/restore in qa directory (copy them here) for debugging
17 export PATH="$here:$PATH"
18 export XFSDUMP_PROG="`set_prog_path xfsdump`"
19 export XFSRESTORE_PROG="`set_prog_path xfsrestore`"
20 export XFSINVUTIL_PROG="`set_prog_path 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" = "" ] && _fatal "xfsdump not found"
27 [ "$XFSRESTORE_PROG" = "" ] && _fatal "xfsrestore not found"
28 [ "$XFSINVUTIL_PROG" = "" ] && _fatal "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
51 trap "_cleanup; exit \$status" 0 1 2 3 15
53 # start inventory from a known base - move it aside for test
54 for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
56 [ -d $dir.$seq ] && rm -rf $dir.$seq
62 [ `uname` = "Linux" ] && have_mtvariable=true
65 # do a remote/local mt
72 _rmtdev=`echo $dumptape | $AWK_PROG -F: '{print $2}'`
74 if echo $dumptape | grep '@' >/dev/null; then
75 _spec=`echo $dumptape | $AWK_PROG -F: '{print $1}'`
76 _rmtuser=`echo $_spec | $AWK_PROG -F@ '{print $1}'`
77 _rmthost=`echo $_spec | $AWK_PROG -F@ '{print $2}'`
78 rsh -n -l $_rmtuser $_rmthost "mt -t $_rmtdev $op"
80 _rmthost=`echo $dumptape | $AWK_PROG -F: '{print $1}'`
81 rsh -n $_rmthost "mt -t $_rmtdev $op"
93 while [ $i -lt $_limit ]; do
94 echo "Checking online..." >>$here/$seq.full
95 if _mt status >$tmp.status 2>&1; then
104 if [ $i -eq $_limit ]; then
105 echo "ERROR: mt -f $dumptape failed"
108 echo "mt -f $dumptape failed" >$seq.notrun
114 if egrep -i 'onl|ready' $tmp.status | grep -iv 'not ready' >/dev/null; then
117 echo "ERROR: $dumptape is not online"
120 echo "dumptape, $dumptape, is not online" >$seq.notrun
128 echo "Wait for tape, $dumptape, ..." >>$here/$seq.full
131 while [ $i -lt 20 ]; do
132 echo "Checking status..." >>$here/$seq.full
133 if _mt status 2>&1 | tee -a $here/$seq.full | egrep -i "onl|ready" >/dev/null; then
143 # Keep trying so we know we really have rewound
147 echo "Initiate rewind..." >>$here/$seq.full
149 _mt rewind >/dev/null
154 # Do a custom erase because:
155 # (i) some machines don't support it
156 # (ii) some machines take forever to do it
160 echo "Erasing tape" | tee -a $here/$seq.full
168 echo "Erasing tape" | tee -a $here/$seq.full
174 echo $dumptape | grep ':' >/dev/null
182 $have_mtvariable || return
188 echo "Put scsi tape driver into variable block size mode"
189 mt -f $dumptape setblk 0
197 if [ -z "$dumptape" -o "@" == "$dumptape" ]; then
198 echo "This test requires a dump tape - none was specified"
199 echo "No dump tape specified" >$seq.notrun
212 _scratch_mkfs_xfs >>$here/$seq.full || _fail "mkfs failed"
213 _scratch_mount >>$here/$seq.full || _fail "mount failed"
217 # Cleanup created dirs and files
225 if [ -n "$DEBUGDUMP" ]; then
226 # save it for inspection
227 for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
228 [ -d $dir ] || continue
229 tar -cvf $seq.inventory.tar $dir
230 ls -nR $dir >$seq.inventory.ls
234 # put inventory dir back
235 for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
236 [ -d $dir.$seq ] || continue
237 rm -rf $dir # get rid of new one
241 if [ $status -ne $NOTRUNSTS ]; then
242 # Sleep added to stop _check_scratch_fs from complaining that the
243 # scratch_dev is still busy
251 # ensure that bulkstat data will
252 # match with incore data
253 # by forcing disk data to be written out
257 _saveddir=`pwd`; cd /
258 umount $SCRATCH_MNT >>$here/$seq.full || _fail "unmount failed"
259 _scratch_mount >>$here/$seq.full || _fail "mount failed"
264 # Run fsstress to create a mixture of
265 # files,dirs,links,symlinks
267 # Pinched from test 013.
269 _create_dumpdir_stress()
271 echo "Creating directory system to dump using fsstress."
275 _param="-f link=10 -f creat=10 -f mkdir=10 -f truncate=5 -f symlink=10"
278 if ! mkdir $dump_dir; then
279 echo " failed to mkdir $dump_dir"
284 echo "-----------------------------------------------"
285 echo "fsstress : $_param"
286 echo "-----------------------------------------------"
287 if ! $here/ltp/fsstress $_param -s 1 $FSSTRESS_AVOID -n $_count -d $dump_dir >$tmp.out 2>&1
289 echo " fsstress (count=$_count) returned $? - see $here/$seq.full"
291 echo "--------------------------------------" >>$here/$seq.full
292 echo "output from fsstress:" >>$here/$seq.full
293 echo "--------------------------------------" >>$here/$seq.full
294 cat $tmp.out >>$here/$seq.full
303 cat <<End-of-File >$tmp.config
304 # pathname size in bytes owner group
306 small 10 $nobody $nobody
307 big 102400 daemon sys
309 sub/big 102400 $nobody sys
311 sub/a 1 $nobody $nobody
312 sub/b 2 $nobody $nobody
313 sub/c 4 $nobody $nobody
314 sub/d 8 $nobody $nobody
315 sub/e 16 $nobody $nobody
316 sub/f 32 $nobody $nobody
317 sub/g 64 $nobody $nobody
318 sub/h 128 $nobody $nobody
319 sub/i 256 $nobody $nobody
320 sub/j 512 $nobody $nobody
321 sub/k 1024 $nobody $nobody
322 sub/l 2048 $nobody $nobody
323 sub/m 4096 $nobody $nobody
324 sub/n 8192 $nobody $nobody
326 sub/a00 100 $nobody $nobody
327 sub/b00 200 $nobody $nobody
328 sub/c00 400 $nobody $nobody
329 sub/d00 800 $nobody $nobody
330 sub/e00 1600 $nobody $nobody
331 sub/f00 3200 $nobody $nobody
332 sub/g00 6400 $nobody $nobody
333 sub/h00 12800 $nobody $nobody
334 sub/i00 25600 $nobody $nobody
335 sub/j00 51200 $nobody $nobody
336 sub/k00 102400 $nobody $nobody
337 sub/l00 204800 $nobody $nobody
338 sub/m00 409600 $nobody $nobody
339 sub/n00 819200 $nobody $nobody
341 sub/a000 1000 $nobody $nobody
342 sub/e000 16000 $nobody $nobody
343 sub/h000 128000 $nobody $nobody
344 sub/k000 1024000 $nobody $nobody
350 cat <<End-of-File >$tmp.config
351 # pathname size in bytes
353 smalll 10 $nobody $nobody
354 biggg 102400 $nobody $nobody
355 sub/smalll 10 $nobody $nobody
356 sub/biggg 102400 $nobody $nobody
360 _mk_fillconfig_perm()
362 # dir_guid: ugo=rwx,g+s on dir is for IRIX chmod(1)
364 cat <<End-of-File >$tmp.config
365 # pathname size/dir user group mode
367 file_suid 10 $nobody $nobody 04777
368 file_guid 10 $nobody $nobody 02777
369 file_sticky 10 $nobody $nobody 01777
370 file_mix1 10 $nobody $nobody 761
371 file_mix2 10 $nobody $nobody 642
372 dir_suid d $nobody $nobody 04777
373 dir_guid d $nobody $nobody ugo=rwx,g+s
374 dir_sticky d $nobody $nobody 01777
375 dir_mix1 d $nobody $nobody 761
376 dir_mix2 d $nobody $nobody 642
382 cat <<End-of-File >$tmp.config
383 # pathname size user group perm name value namespace
385 smalll 10 $nobody $nobody 777 attr1 some_text user
386 biggg 102400 $nobody $nobody 777 attr2 some_text2 root
387 sub/smalll 10 $nobody $nobody 777 attr3 some_text3 user
388 sub/biggg 102400 $nobody $nobody 777 attr4 some_text4 root
389 dir d $nobody $nobody 777 attr5 dir_text user
391 # Add more files so that there are more than the number
393 # There are bugs in dump/restore for # non-dir files < # streams
394 # It can be tested in another configuration.
395 # It is a pathalogical case.
397 sub/a 1 $nobody $nobody
398 sub/b 2 $nobody $nobody
399 sub/c 4 $nobody $nobody
400 sub/d 8 $nobody $nobody
401 sub/e 16 $nobody $nobody
402 sub/f 32 $nobody $nobody
403 sub/g 64 $nobody $nobody
404 sub/h 128 $nobody $nobody
405 sub/i 256 $nobody $nobody
406 sub/j 512 $nobody $nobody
407 sub/k 1024 $nobody $nobody
408 sub/l 2048 $nobody $nobody
409 sub/m 4096 $nobody $nobody
410 sub/n 8192 $nobody $nobody
415 # extended file attribute flags
417 _mk_fillconfig_xattr()
419 cat <<End-of-File >$tmp.config
420 # pathname size user group perm name
422 xflag_realtime 10 $nobody $nobody 777 XFS_XFLAG_REALTIME
423 xflag_prealloc 10 $nobody $nobody 777 XFS_XFLAG_PREALLOC
424 xflag_immutable 10 $nobody $nobody 777 XFS_XFLAG_IMMUTABLE
425 xflag_append 10 $nobody $nobody 777 XFS_XFLAG_APPEND
426 xflag_sync 10 $nobody $nobody 777 XFS_XFLAG_SYNC
427 xflag_noatime 10 $nobody $nobody 777 XFS_XFLAG_NOATIME
428 xflag_nodump 10 $nobody $nobody 777 XFS_XFLAG_NODUMP
429 xflag_hasattr 10 $nobody $nobody 777 XFS_XFLAG_HASATTR
434 # Create a bunch of directories/files of different sizes
437 # Pinched from test 001.
439 _do_create_dumpdir_fill()
441 echo "Creating directory system to dump using src/fill."
443 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
446 $verbose && echo -n "Setup "
447 sed -e '/^#/d' $tmp.config \
448 | while read file nbytes owner group perms ea_name ea_value namespace
450 if [ $nbytes = "d" ]; then
460 echo "Error: cannot mkdir \"$dir\""
465 # create a directory/file
476 echo "Error: cannot mkdir \"$dir\""
482 if $here/src/fill $file $file $nbytes
487 echo "Error: cannot create \"$file\""
491 if [ -n "$owner" -a -n "$group" ]; then
492 chown $owner.$group $file
494 if [ -n "$perms" ]; then
498 # extended attributes (EA)
499 if [ -n "$ea_name" -a -n "$ea_value" ]; then
500 if [ "X$namespace" = "Xroot" ]; then
501 attr -R -s $ea_name -V $ea_value $file
503 attr -s $ea_name -V $ea_value $file
505 # extended file attribute flags - no value - NOT EAs
506 elif [ -n "$ea_name" -a -z "$ea_value" ]; then
509 # use xfs_io to send the ioctl
512 $verbose && echo -n "."
519 _create_dumpdir_largefile()
522 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
523 _largesize=4294967297
524 _largefile=$dump_dir/largefile
525 echo "dd a largefile at offset $_largesize"
526 POSIXLY_CORRECT=yes \
527 dd if=/dev/zero of=$_largefile bs=1 seek=$_largesize count=10 2>&1
531 _create_dumpdir_fill()
535 _do_create_dumpdir_fill
539 _create_dumpdir_fill2()
543 _do_create_dumpdir_fill
547 _create_dumpdir_fill_perm()
551 _do_create_dumpdir_fill
555 _create_dumpdir_fill_ea()
559 _do_create_dumpdir_fill
565 # Append a subset of the fill'ed files
566 # So we can see if just these get dumped on an incremental
568 _append_dumpdir_fill()
571 cat <<End-of-File >$tmp.config
581 sed -e '/^#/d' $tmp.config \
584 echo 'Extra text' >>$file
591 _do_create_dump_symlinks()
593 echo "Creating directory system of symlinks to dump."
595 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
598 $verbose && echo -n "Setup "
599 sed -e '/^#/d' $tmp.config \
600 | while read file nbytes owner group owner2 group2 perms perms2
612 echo "Error: cannot mkdir \"$dir\""
620 # Do chmod on symlink using umask.
621 # This won't do the right thing as it subtracts permissions.
622 # However, I don't care, as long as I get some different perms
624 if [ -n "$perms2" ]; then
628 ln -s $file $file-link
629 if [ -n "$perms2" ]; then
633 if [ -n "$owner" -a -n "$group" ]; then
634 chown $owner.$group $file
636 if [ -n "$owner" -a -n "$group" ]; then
637 chown -h $owner.$group $file-link
639 if [ -n "$perms" ]; then
642 $verbose && echo -n "."
651 cat <<End-of-File >$tmp.config
652 # path size owner1 group1 owner2 group2 perm1 perm2
654 a 0 $nobody $nobody daemon sys 124 421
655 b 0 daemon sys bin bin 347 743
656 sub/a 0 bin bin $nobody sys 777 777
657 sub/b 0 $nobody sys $nobody $nobody 367 763
661 _create_dumpdir_symlinks()
665 _do_create_dump_symlinks
670 # create hardlinks of form $_fname, $_fname_h1 $_fname_h2 ...
679 while [ $_j -le $_numlinks ]; do
681 _hardlink=$_fname$_suffix
682 echo "creating hardlink $_hardlink to $_fname"
683 ln $_fname $_hardlink
689 # create a set of hardlinks
690 # create hardlinks of form file1, file1_h1 file1_h2 ...
691 # create hardlinks of form file2, file2_h1 file2_h2 ...
692 # create hardlinks of form file3, file3_h1 file3_h2 ...
698 while [ $_i -le $_numsets ]; do
699 _create_hardlinks file$_i 5
708 echo "mod level $_level" >$dump_dir/file$_level
711 _create_dumpdir_hardlinks()
715 echo "Creating directory system of hardlinks to incrementally dump."
717 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
720 _create_hardset $_numsets
728 # Filter out times and dates on symlinks and char devices.
729 # Filter out size on directories because this can differ
730 # when transitioning to long inode numbers (ie. 64 bits).
735 /^l/ { date = $8; time = $7; sub(date,"DATE"); sub(time,"TIME"); print}
736 /^c/ { date = $9; time = $7; sub(date,"DATE"); sub(time,"TIME"); print}
737 /^d/ { size = $5; sub(size,"SIZE"); print}
739 | sed -e 's/total [0-9][0-9]*/total TOTAL/'
743 # Filtering of Irix character hwgraph device names
745 # chardev: /hw/node/xtalk/15/pci/0/scsi_ctlr/0/target/1/lun/0/disk/partition/4/char
746 # blkdev: /dev/dsk/dks0d1s4
752 sub(/\/hw.*scsi_ctlr\//,"/dev/dsk/dks") # blah blah /dev/dsk/dks0/target/1/....
753 sub(/\/target\//,"d") # blah blah /dev/dsk/dks0d1/lun/0/disk.....
754 sub(/\/lun.*partition\//,"s") # blah blah /dev/dsk/dks0d1s4/char
755 sub(/\/char/,"") # blah blah /dev/dsk/dks0d1s4
763 # Filter out the non-deterministic dump msgs from
764 # xfsdump and xfsrestore
770 -e "s#$XFSDUMP_PROG#xfsdump#" \
771 -e "s#$XFSRESTORE_PROG#xfsrestore#" \
772 -e "s#$XFSINVUTIL_PROG#xfsinvutil#" \
773 -e "s/`hostname`/HOSTNAME/" \
774 -e "s#$SCRATCH_DEV#SCRATCH_DEV#" \
775 -e "s#$SCRATCH_RAWDEV#SCRATCH_DEV#" \
776 -e "s#$dumptape#TAPE_DEV#" \
777 -e "s#$SCRATCH_MNT#SCRATCH_MNT#" \
778 -e "s#$dump_file#DUMP_FILE#" \
779 -e 's#/var/lib/xfsdump#/var/xfsdump#' \
780 -e 's/session id:[ ]*[0-9a-f-]*/session id: ID/' \
781 -e '/filesystem id:[ ]*[0-9a-f-]*/d' \
782 -e 's/time:[ ].*/time: TIME/' \
783 -e 's/date:[ ].*/date: DATE/' \
784 -e 's/dump begun .*/dump begun DATE/' \
785 -e 's/[0-9][0-9]* seconds/SECS seconds/' \
786 -e 's/restore.[0-9][0-9]*/restore.PID/' \
787 -e 's/ino [0-9][0-9]*/ino INO/' \
788 -e '/: dump size/s/[0-9][0-9]*/NUM/' \
789 -e '/dump size:/s/[0-9][0-9]*/NUM/' \
790 -e '/dump size per stream:/s/[0-9][0-9]*/NUM/' \
791 -e 's/\(media file size[ ]*\)[0-9][0-9]*/\1NUM/' \
792 -e 's/\(mfile size:[ ]*\)[0-9][0-9]*/\1NUM/' \
793 -e '/drive[ ]*[0-9][0-9]*:/d' \
795 -e '/inventory session uuid/d' \
796 -e '/ - Running single-threaded/d' \
797 -e '/^.*I\/O metrics: .*$/d' \
798 -e 's/1048576/BLOCKSZ/' \
799 -e 's/2097152/BLOCKSZ/' \
800 -e 's/(pid[ ]*[1-9][0-9]*)/\(pid PID\)/' \
801 -e '/version 3\.0/d' \
802 -e 's/\/hw\/module.*$/SCRATCH_DEV/' \
803 -e 's/xfsdump: ino map phase 1: .*/xfsdump: ino map <PHASES>/' \
804 -e '/xfsdump: ino map phase [2]/,1d' \
805 -e '/xfsdump: ino map phase [3]/,1d' \
806 -e '/xfsdump: ino map phase [4]/,1d' \
807 -e '/xfsdump: ino map phase [5]/,1d' \
808 -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/' \
809 -e 's/\[y\/n\][- ]----------------------*/\[y\/n\]/' \
811 if ($_ =~ /(?:Dump|Restore) Summary/) {
813 } elsif ($_ =~ /(?:Dump|Restore) Status/) {
823 _dump_filter_main | _check_quota_dumprestore | _check_quota_entries
833 -e 's/UUID[ ]*:[ ][0-9a-f-]*/UUID : ID/' \
834 -e 's/TIME OF DUMP[ ]*:.*/TIME OF DUMP : TIME/' \
835 -e 's/HOSTNAME:SCRATCH_MNT.*/HOSTNAME:SCRATCH_MNT/' \
836 -e 's#inventory/[0-9a-f-]*#inventory/UUID#' \
844 -e "s#$dump_file#DUMP_FILE#" \
845 -e "s#$SCRATCH_DEV#SCRATCH_DEV#" \
846 -e "s#$SCRATCH_RAWDEV#SCRATCH_DEV#" \
847 -e "s#$dumptape#TAPE_DEV#" \
848 -e "s#$dump_dir#DUMP_DIR#g" \
849 -e "s#$restore_dir#RESTORE_DIR#g" \
850 -e "s#$SCRATCH_MNT#SCRATCH_MNT#g" \
851 -e "s#$dump_sdir#DUMP_SUBDIR#g" \
852 -e "s#$restore_sdir#RESTORE_SUBDIR#g" \
858 # Note: requires a space between option letter and argument
869 [ -z "$2" ] && _fail "missing argument for -f"
874 [ -z "$2" ] && _fail "missing argument for -L"
879 dump_args="$dump_args -o"
882 dump_args="$dump_args -F"
895 [ -z "$2" ] && _fail "missing argument for -l"
896 dump_args="$dump_args -l$2"
900 _fail "invalid argument to common.dump function: $1"
915 echo "Dumping to tape..."
916 opts="$_dump_debug$dump_args -s $dump_sdir -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
917 echo "xfsdump $opts" | _dir_filter
918 $XFSDUMP_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
928 echo "Dumping to tape..."
929 opts="$_dump_debug$dump_args -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
930 echo "xfsdump $opts" | _dir_filter
931 $XFSDUMP_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
936 # Do full dump with -m
942 echo "Dumping to tape..."
944 opts="$_dump_debug$dump_args -m -b $onemeg -l0 -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
945 echo "xfsdump $opts" | _dir_filter
946 $XFSDUMP_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
951 # Do full dump to file
957 echo "Dumping to file..."
958 opts="$_dump_debug$dump_args -f $dump_file -M $media_label -L $session_label $SCRATCH_MNT"
959 echo "xfsdump $opts" | _dir_filter
960 $XFSDUMP_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
964 # Do full dump to multiple files
966 _do_dump_multi_file()
973 while [ $i -lt $multi ]
975 multi_args="$multi_args -f $dump_file.$i -M $media_label.$i"
979 echo "Dumping to files..."
980 opts="$_dump_debug$dump_args $multi_args -L $session_label $SCRATCH_MNT"
981 echo "xfsdump $opts" | _dir_filter
982 $XFSDUMP_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
986 _prepare_restore_dir()
989 mkdir $restore_dir || _fail "failed to mkdir $restore_dir"
994 # Get tape ready and restore dir
1000 echo "Rewinding tape"
1005 # Restore the tape into $restore_dir
1013 echo "Restoring from tape..."
1014 opts="$_restore_debug -f $dumptape -L $session_label $restore_dir"
1015 echo "xfsrestore $opts" | _dir_filter
1016 $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1020 # Restore the tape into $restore_dir using -m
1027 echo "Restoring from tape..."
1029 opts="$_restore_debug -m -b $onemeg -f $dumptape -L $session_label $restore_dir"
1030 echo "xfsrestore $opts" | _dir_filter
1031 $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1035 # Restore the tape from a dump file
1040 _prepare_restore_dir
1042 echo "Restoring from file..."
1043 opts="$_restore_debug -f $dump_file -L $session_label $restore_dir"
1044 echo "xfsrestore $opts" | _dir_filter
1045 $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1049 # Cumulative restore from a file
1050 # Need to specify the dump level e.g. "-l 0"
1052 _do_restore_file_cum()
1055 if echo $dump_args | grep '\-l0' >/dev/null; then
1056 _prepare_restore_dir
1059 echo "Restoring cumumlative from file..."
1060 opts="$_restore_debug -f $dump_file -r $restore_dir"
1061 echo "xfsrestore $opts" | _dir_filter
1062 $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1067 echo "Contents of dump ..."
1068 opts="$_restore_debug -f $dump_file -t"
1069 echo "xfsrestore $opts" | _dir_filter
1070 cd $SCRATCH_MNT # for IRIX which needs xfs cwd
1071 $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter_main |\
1072 _check_quota_file |\
1073 _check_quota_entries |\
1074 $AWK_PROG 'NF != 1 { print; next }
1075 {files = sprintf("%s\n%s", files, $1)}
1076 END { print files | "sort" } '
1077 # the above awk code is to alpha sort only the output
1078 # of files (and not the verbose restore msgs)
1083 # Restore the tape from multiple dump files
1085 _do_restore_multi_file()
1088 _prepare_restore_dir
1093 while [ $i -lt $multi ]
1095 multi_args="$multi_args -f $dump_file.$i"
1099 echo "Restoring from file..."
1100 opts="$_restore_debug $multi_args -L $session_label $restore_dir"
1101 echo "xfsrestore $opts" | _dir_filter
1102 $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1106 # Do xfsdump piped into xfsrestore - xfsdump | xfsrestore
1108 # Use -s as we want to dump and restore to the same xfs partition
1113 _prepare_restore_dir
1114 echo "xfsdump|xfsrestore ..."
1115 restore_opts="$_restore_debug - $restore_dir"
1116 dump_opts="$_dump_debug$dump_args -s $dump_sdir - $SCRATCH_MNT"
1117 echo "xfsdump $dump_opts | xfsrestore $restore_opts" | _dir_filter
1118 $XFSDUMP_PROG $dump_opts 2>$tmp.dump.mlog | $XFSRESTORE_PROG $restore_opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1119 _dump_filter <$tmp.dump.mlog
1123 # Compare dumped subdirectory with restored dir
1125 # Thus no contents are compared but permissions, sizes,
1126 # owners, etc... are.
1131 # verify we got back what we dumped
1133 echo "Comparing listing of dump directory with restore directory"
1134 ls -nR $dump_dir | tee -a $here/$seq.full | _ls_filter >$tmp.dump_dir
1135 ls -nR $restore_dir/$dump_sdir | tee -a $here/$seq.full | _ls_filter \
1136 | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
1138 diff -bcs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
1142 # filter out the date fields
1146 $AWK_PROG 'NF == 9 { print $1, $2, $3, $4, $9 }'
1150 # _ls_compare_sub but don't compare dates
1151 _ls_nodate_compare_sub()
1154 # verify we got back what we dumped
1156 echo "Comparing listing of dump directory with restore directory"
1157 ls -nR $dump_dir | tee -a $here/$seq.full | _ls_filter | _ls_nodate_filter >$tmp.dump_dir
1158 ls -nR $restore_dir/$dump_sdir | tee -a $here/$seq.full | _ls_filter \
1159 | _ls_nodate_filter | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
1161 diff -bcs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
1165 # Compare using recursive diff the files of the dumped
1167 # This one will compare the contents.
1171 echo "Comparing dump directory with restore directory"
1172 diff -rs $dump_dir $restore_dir/$dump_sdir | _dir_filter
1179 # Tim - this is the IRIX way...
1180 # find $_path -exec attr -l {} \; |\
1181 # awk '{print $9, $2}' |\
1184 # and this is now the Linux way...
1186 getfattr --absolute-names -Rh -m user $_path |\
1188 if (m/^# file: (\S+)/) { $file = $1 }
1189 elsif (m/^user\.(\w+)/) { print $file, " ",$1,"\n" }' |\
1191 while read file ea_name; do
1192 attr -g $ea_name $file
1195 if [ "$USE_ATTR_SECURE" = yes ]; then
1196 echo "Security names"
1197 getfattr --absolute-names -Rh -m security $_path |\
1199 if (m/^# file: (\S+)/) { $file = $1 }
1200 elsif (m/^security\.(\w+)/) { print $file, " ",$1,"\n" }' |\
1202 while read file ea_name; do
1203 attr -g $ea_name $file
1208 getfattr --absolute-names -Rh -m trusted $_path |\
1210 if (m/^# file: (\S+)/) { $file = $1 }
1211 elsif (m/^trusted\.(\w+)/) { print $file, " ",$1,"\n" }' |\
1213 while read file ea_name; do
1214 attr -R -g $ea_name $file
1219 # Compare the extended attributes of the files/dirs
1220 # b/w the dumped and restore dirs.
1223 # Attribute "attr5" had a 8 byte value for /spare1/dump.5460/dir:
1224 # Attribute "attr5" had a 8 byte value for /spare1/restore.5460/dump.5460/dir:
1228 echo "Comparing dump directory with restore directory"
1229 echo "Looking at the extended attributes (EAs)"
1231 _get_eas_on_path $dump_dir | tee $seq.ea1 | _dir_filter
1232 echo "EAs on restore"
1233 _get_eas_on_path $restore_dir/$dump_sdir \
1234 | sed -e "s#$restore_sdir\/##" \
1237 diff -s $seq.ea1 $seq.ea2
1242 # Compare using recursive diff the files of the dumped
1247 echo "Comparing dump directory with restore directory"
1248 diff -rs $SCRATCH_MNT $restore_dir | _dir_filter | _check_quota_diff
1252 # Check out the dump inventory
1256 $XFSDUMP_PROG $_dump_debug -I | tee -a $here/$seq.full | _dump_filter_main
1260 # Do the xfsinvutil cmd with debug and filters
1261 # Need to set variable: "$middate" to the invutil date
1266 echo "xfsinvutil $_invutil_debug -M $host:$SCRATCH_MNT \"$middate\" $*" >$here/$seq.full
1267 $XFSINVUTIL_PROG $_invutil_debug $* -M $host:$SCRATCH_MNT "$middate" \
1268 | tee -a $here/$seq.full | _invutil_filter
1272 # ensure we can find the user quota msg if user quotas are on
1273 # ensure we can find the group quota msg if group quotas are on
1283 $here/src/feature -U $SCRATCH_DEV && uquota=1
1284 $here/src/feature -G $SCRATCH_DEV && gquota=1
1285 $here/src/feature -P $SCRATCH_DEV && pquota=1
1287 $AWK_PROG -v uquota=$uquota -v gquota=$gquota -v pquota=$pquota \
1288 -v full=$here/$seq.full -v usermsg="$usermsg" \
1289 -v groupmsg="$groupmsg" -v projectmsg="$projectmsg" '
1291 print "Found project quota:", $0 >>full
1294 print "Found extra:", $0
1299 print "Found group quota:", $0 >>full
1302 print "Found extra:", $0
1307 print "Found user quota:", $0 >>full
1310 print "Found extra:", $0
1316 if (uquota && !found_uquota) {
1317 print "Missing user quota msg:", usermsg
1319 if (gquota && !found_gquota) {
1320 print "Missing group quota msg:", groupmsg
1322 if (pquota && !found_pquota) {
1323 print "Missing project quota msg:", projectmsg
1330 # xfsrestore: 3 directories and 40 entries processed
1332 # num entries needs to be reduced by num quota file(s)
1334 _check_quota_entries()
1339 $here/src/feature -U $SCRATCH_DEV && uquota=1
1340 $here/src/feature -G $SCRATCH_DEV && gquota=1
1341 $here/src/feature -P $SCRATCH_DEV && pquota=1
1342 $AWK_PROG -v uquota=$uquota -v gquota=$gquota -v pquota=$pquota '
1343 /entries processed/ {
1353 # xfsdump: saving user quota information for: SCRATCH_MNT
1354 # xfsdump: saving group quota information for: SCRATCH_MNT
1355 # xfsdump: saving project quota information for: SCRATCH_MNT
1356 # xfsrestore: user quota information written to ...'
1357 # xfsrestore: group quota information written to ...'
1358 # xfsrestore: project quota information written to ...'
1360 # If on IRIX then look for:
1361 # xfsrestore: use 'edquota' to restore quotas
1363 # xfsrestore: use 'xfs_quota' to restore quotas
1365 _check_quota_dumprestore()
1367 if [ "$HOSTOS" == "IRIX" ]; then
1368 _check_quota 'user quota information' \
1369 'group quota information' \
1370 'project quota information' | \
1371 sed "/xfsrestore:.*use 'edquota' to restore quotas/d"
1373 _check_quota 'user quota information' \
1374 'group quota information' \
1375 'project quota information' | \
1376 sed "/xfsrestore:.*use 'xfs_quota' to restore quotas/d"
1382 # Only in RESTORE_DIR: xfsdump_quotas
1383 # Only in RESTORE_DIR: xfsdump_quotas_group
1384 # Only in RESTORE_DIR: xfsdump_quotas_project
1388 _check_quota 'Only in RESTORE_DIR: xfsdump_quotas' \
1389 'Only in RESTORE_DIR: xfsdump_quotas_group' \
1390 'Only in RESTORE_DIR: xfsdump_quotas_proj'
1394 # Look for the quota file in the output
1395 # Ensure that it is there if it should be
1396 # Filter it out so that the output is always the same
1397 # even with no quotas
1401 _check_quota 'xfsdump_quotas' 'xfsdump_quotas_group' 'xfsdump_quotas_proj'
1405 # make sure this script returns success