3 # Copyright (C) 2000-2017 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
6 # Run a simple backup of the Bacula build directory
7 # then restore one file and see if we read too much
10 # With AWK, we get the 1st executable file from the volume we get the also a
11 # "position" of the file in the volume with NR (line number).
13 # With grep "FI=nn SessId=", we search in the trace file up to which FI we read the data.
15 # For example, if we find build/libtool NR=6, the trace file should have all
16 # FileIndex<6 (probably between 3 and 5) If we find a FI=6 in the trace file,
17 # it means that we read too much data
19 TestName="restore-stop-read-test"
27 # Zap out any schedule in default conf file so that
28 # it doesn't start during our test
31 echo "s% Schedule =%# Schedule =%g" >${outf}
32 cp $scripts/bacula-dir.conf $tmp/1
33 sed -f ${outf} $tmp/1 >$scripts/bacula-dir.conf
35 $bperl -e "add_attribute('$conf/bacula-sd.conf', 'MaximumFileSize', '10MB', 'Device')"
36 director=`$bperl -e "get_dirname()"`
38 change_jobname BackupClient1 $JobName
41 cat <<END_OF_DATA >$tmp/bconcmds
45 label volume=TestVolume001 storage=File1 pool=File slot=1 drive=0
54 $bin/bls -V TestVolume001 FileChgr1-Dev1 > $tmp/list
56 f=`awk '/-rwxr-xr-x/ { print $11; exit }' $tmp/list`
58 # The "line" in the bls is between 3-n, the fileindex (one by line)
59 # is between 1-n. So we search for FI=line, like FI=fileindex+3
60 line=`awk '/-rwxr-xr-x/ { print NR; exit }' $tmp/list`
62 if [ "x$f" = x ]; then
63 print_debug "ERROR: Unable to find a file in the backup list"
70 cat <<END_OF_DATA >$tmp/bconcmds
75 setdebug level=500 trace=1 storage=File1
76 restore where=$tmp/bacula-restores
82 @exec "cp $working/$director.restore.1.bsr $working/restore1.bsr"
86 setdebug level=0 trace=0 storage=File1
92 print_debug "Looking for FI=$line in the SD working/*trace file"
93 # We have more or less one FI per line
94 grep "FI=$line SessId=" working/*trace > /dev/null
96 print_debug "ERROR: Should not find references to FileIndex $line in trace, should stop before"
100 # The "line" in the bls is between 3-n, the fileindex (one by line)
101 # is between 1-n. So we search for FI=line, like FI=fileindex+3
102 f=`awk '/-rwxr-xr-x/ { if (count++ == 10) { print $11; exit} }' $tmp/list`
103 line=`awk '/-rwxr-xr-x/ { if(count++ == 10) {print NR; exit}}' $tmp/list`
105 if [ "x$f" = x ]; then
106 print_debug "ERROR: Unable to find a file=$file in the backup list"
113 cat <<END_OF_DATA >$tmp/bconcmds
118 setdebug level=500 trace=1 storage=File1
119 restore where=$tmp/bacula-restores
127 setdebug level=0 trace=0 storage=File1
133 # We have more or less one FI per line
134 print_debug "Looking for file=$f FI=$line in the SD trace file"
135 grep "FI=$line SessId=" working/*trace > /dev/null
136 if [ $? -eq 0 ]; then
137 print_debug "ERROR: Should not find references to FileIndex $line in trace, should stop before"
141 check_for_zombie_jobs storage=File1