# do a bscan and restore.
# It should require at least 4 different bsrs.
#
-debug=0
-if test "$debug" -eq 1 ; then
- out="tee"
-else
- out="output"
-fi
-
-cwd=`pwd`
-scripts/copy-tape-confs
-scripts/cleanup-tape
+TestName="bscan-tape"
+JobName=bscantape
+. scripts/functions
+set_debug 0
+
+copy_tape_confs
+
echo "${cwd}/build" >/tmp/file-list
cp ${cwd}/bin/bacula-sd.conf ${cwd}/tmp/1
sed "s%# Maximum File Size% Maximum File Size%" ${cwd}/tmp/1 >${cwd}/bin/bacula-sd.conf
-echo " "
-echo " "
-echo " === Starting bscan-tape at `date +%R:%S` ==="
-echo " === Starting bscan-tape at `date +%R:%S` ===" >>working/log
-echo " "
+change_jobname NightlySave $JobName
+start_test
cat <<END_OF_DATA >tmp/bconcmds
-@$out /dev/null
-estimate job=NightlySave listing
-estimate job=NightlySave listing
-estimate job=NightlySave listing
+@output /dev/null
+estimate job=$JobName listing
+estimate job=$JobName listing
+estimate job=$JobName listing
messages
@$out tmp/log1.out
setdebug level=2 storage=DDS-4
label storage=DDS-4 volume=TestVolume001 slot=0 pool=Default
-run job=NightlySave yes
+run job=$JobName yes
wait
-run job=NightlySave level=Full yes
+run job=$JobName level=Full yes
wait
-run job=NightlySave level=Full yes
+run job=$JobName level=Full yes
wait
messages
quit
END_OF_DATA
-if test "$debug" -eq 1 ; then
- bin/bacula start
- cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
-else
- bin/bacula start 2>&1 >/dev/null
- cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf 2>&1 >/dev/null
-fi
-scripts/check_for_zombie_jobs storage=DDS-4
+run_bacula
+check_for_zombie_jobs storage=DDS-4
+
echo "Backup 1 done"
# make some files for the incremental to pick up
touch ${cwd}/build/src/dird/*.c ${cwd}/build/src/dird/*.o
@$out /dev/null
messages
@$out tmp/log1.out
-run job=NightlySave level=Incremental yes
+run job=$JobName level=Incremental yes
wait
messages
quit
END_OF_DATA
-if test "$debug" -eq 1 ; then
- bin/bacula start
- cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
-else
- bin/bacula start 2>&1 >/dev/null
- cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf 2>&1 >/dev/null
-fi
+run_bacula
scripts/check_for_zombie_jobs storage=DDS-4
+
echo "Backup 2 done"
touch ${cwd}/build/src/dird/*.c
touch ${cwd}/build/src/lib/*.c ${cwd}/build/src/lib/*.o
@$out /dev/null
messages
@$out tmp/log1.out
-run job=NightlySave level=Incremental yes
+run job=$JobName level=Incremental yes
wait
messages
quit
END_OF_DATA
-if test "$debug" -eq 1 ; then
- bin/bacula start
- cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
-else
- bin/bacula start 2>&1 >/dev/null
- cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf 2>&1 >/dev/null
-fi
+run_bacula
scripts/check_for_zombie_jobs storage=DDS-4
+
echo "Backup 3 done"
# make some files for the incremental to pick up
touch ${cwd}/build/src/lib/*.c ${cwd}/build/src/lib/*.o
#
# run a fourth job
#
-
cat <<END_OF_DATA >tmp/bconcmds
@$out /dev/null
messages
@$out tmp/log1.out
-run job=NightlySave level=Incremental yes
+run job=$JobName level=Incremental yes
wait
messages
quit
END_OF_DATA
-if test "$debug" -eq 1 ; then
- bin/bacula start
- cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
-else
- bin/bacula start 2>&1 >/dev/null
- cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf 2>&1 >/dev/null
-fi
+
+run_bacula
scripts/check_for_zombie_jobs storage=DDS-4
+stop_bacula
+
echo "Backup 4 done"
#
# now drop and recreate the database
./grant_bacula_privileges 2>&1 >/dev/null
cd ..
-bin/bacula stop 2>&1 >/dev/null
echo "volume=TestVolume001" >tmp/bscan.bsr
bin/bscan -w working -m -s -v -b tmp/bscan.bsr -c bin/bacula-sd.conf DDS-4 2>&1 >/dev/null
-bin/bacula start 2>&1 >/dev/null
-bin/bconsole -c bin/bconsole.conf <<END_OF_DATA 2>&1 >/dev/null
+
+cat <<END_OF_DATA >tmp/bconcmds
@$out /dev/null
messages
@$out tmp/log2.out
@$out
quit
END_OF_DATA
-scripts/check_for_zombie_jobs storage=DDS-4
+
+run_bacula
+check_for_zombie_jobs storage=DDS-4
+stop_bacula
rm -f ${cwd}/build/src/lib/dummy
-bin/bacula stop 2>&1 >/dev/null
-grep "^ Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
-bstat=$?
-grep "^ Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
-rstat=$?
-diff -r build tmp/bacula-restores${cwd}/build 2>&1 >/dev/null
-if [ $? != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
- echo " "
- echo " "
- echo " !!!!! bscan-tape Bacula source failed!!! !!!!! "
- echo " !!!!! bscan-tape failed!!! !!!!! " >>test.out
- echo " "
-else
- echo " ===== bscan-tape Bacula source OK ===== "
- echo " ===== bscan-tape OK ===== " >>test.out
-# scripts/cleanup
-fi
+
+check_two_logs
+check_restore_diff
+end_test