# file size to 1M, it runs very slow. There are about 64 files that
# are created during each of the two backups.
#
-cwd=`pwd`
-bin/bacula stop 2>&1 >/dev/null
-scripts/copy-tape-confs
-scripts/cleanup-tape
-echo "${cwd}/build" >/tmp/file-list
-sed s%\^%${cwd}% ${cwd}/scripts/flist >${cwd}/tmp/restore2-list
-cd bin
-./drop_bacula_tables >/dev/null 2>&1
-./make_bacula_tables >/dev/null 2>&1
-./grant_bacula_privileges 2>&1 >/dev/null
-cd ..
+TestName="restore-by-file-tape"
+JobName=restorebyfile
+. scripts/functions
+copy_tape_confs
+
+echo "${cwd}/build" >${cwd}/tmp/file-list
+sed s%\^%${cwd}% ${cwd}/scripts/flist | sort | uniq >${cwd}/tmp/restore2-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 restore-by-file-tape test ==="
-echo " === Starting restore-by-file-tape test ===" >>working/log
-echo " "
+change_jobname NightlySave $JobName
+start_test
-bin/bacula start 2>&1 >/dev/null
-bin/bconsole -c bin/bconsole.conf <<END_OF_DATA
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
@output /dev/null
messages
-@output tmp/log1.out
-label storage=DDS-4 volume=TestVolume001 slot=0
-run job=NightlySave level=Full yes
+@$out ${cwd}/tmp/log1.out
+label storage=DDS-4 volume=TestVolume001 slot=0 pool=Default
+run job=$JobName level=Full yes
wait
messages
@#
@# now do a restore
@#
-@output tmp/log2.out
+@$out ${cwd}/tmp/log2.out
restore where=${cwd}/tmp/bacula-restores storage=DDS-4 file=<${cwd}/tmp/restore2-list
yes
wait
@output
quit
END_OF_DATA
+
+run_bacula
+check_for_zombie_jobs storage=DDS-4
+stop_bacula
+
dstat=0
-scripts/check_for_zombie_jobs storage=DDS-4
#
# We need to stop and start Bacula to
# test appending to a previously written tape
#
-bin/bacula stop 2>&1 >/dev/null
-bin/bacula start 2>&1 >/dev/null
for i in `cat ${cwd}/tmp/restore2-list`; do
diff $i ${cwd}/tmp/bacula-restores$i
if [ $? != 0 ] ; then
dstat=1
fi
done
-grep "^Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
-bstat=$?
-grep "^Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
-rstat=$?
-if [ $dstat != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
- echo " "
- echo " "
- echo " !!!!! restore-by-file-tape test Bacula source failed!!! !!!!! "
- echo " !!!!! restore-by-file-tape test failed!!! !!!!! " >>test.out
- echo " "
- bin/bacula stop 2>&1 >/dev/null
- exit 1
-else
- echo " First of two restores OK "
-fi
-rm -rf ${cwd}/tmp/bacula-restores
-#
-# Now do a second backup and restore
-#
-bin/bconsole -c bin/bconsole.conf <<END_OF_DATA
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
@output /dev/null
messages
-@output tmp/log1.out
-run job=NightlySave level=Full yes
+@$out ${cwd}/tmp/log1.out
+run job=$JobName level=Full yes
wait
messages
@#
@# now do a restore
@#
-@output tmp/log2.out
+@$out ${cwd}/tmp/log2.out
restore where=${cwd}/tmp/bacula-restores
7
<${cwd}/tmp/restore2-list
@output
quit
END_OF_DATA
+
+#
+# Bacula was stopped, but we must restart it to
+# test appending to a previously written tape
+#
+run_bacula
+check_for_zombie_jobs storage=DDS-4
+stop_bacula
+
+check_two_logs
+
scripts/check_for_zombie_jobs storage=DDS-4
bin/bacula stop 2>&1 >/dev/null
for i in `cat ${cwd}/tmp/restore2-list`; do
dstat=1
fi
done
-grep "^Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
-bstat=$?
-grep "^Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
-rstat=$?
-if [ $dstat != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
- echo " "
- echo " "
- echo " !!!!! restore-by-file-tape test Bacula source failed!!! !!!!! "
- echo " !!!!! restore-by-file-tape test failed!!! !!!!! " >>test.out
- echo " "
-else
- echo " ===== restore-by-file-tape test Bacula source OK ===== "
- echo " ===== restore-by-file-tape test OK ===== " >>test.out
-# scripts/cleanup
-fi
+
+end_test