#!/bin/sh
#
# Run a simple backup of the Bacula build directory
-# to a tape then restore it.
+# to a tape then restore it, we do that twice to ensure that
+# we can correctly append to a tape.
#
cwd=`pwd`
-bin/bacula stop 2>&1 >/dev/null
scripts/copy-tape-confs
scripts/cleanup-tape
+
echo "${cwd}/build" >/tmp/file-list
-bin/drop_sqlite_tables
-bin/make_sqlite_tables
echo " "
echo " "
-echo " === Starting Bacula tape test ==="
-echo " === Starting Bacula tape test ===" >>working/log
+echo " === Starting Backup Bacula tape test at `date +%R:%S` ==="
+echo " === Starting Backup Bacula tape test at `date +%R:%S` ===" >>working/log
echo " "
bin/bacula start 2>&1 >/dev/null
-bin/console -c bin/console.conf <<END_OF_DATA
+bin/bconsole -c bin/bconsole.conf <<END_OF_DATA 2>&1 >/dev/null
@output /dev/null
messages
@output tmp/log1.out
label storage=DDS-4 volume=TestVolume001 slot=0
+purge volume=TestVolume001
+relabel pool=Default storage=DDS-4 oldVolume=TestVolume001 volume=TestVolume002 slot=0
+purge volume=TestVolume002
+relabel pool=Default storage=DDS-4 oldVolume=TestVolume002 volume=TestVolume001 slot=0
run job=NightlySave yes
+status storage=DDS-4
+status storage=DDS-4
+status storage=DDS-4
+status storage=DDS-4
+status storage=DDS-4
+status storage=DDS-4
+sleep 1
+status storage=DDS-4
+status storage=DDS-4
+status storage=DDS-4
+status storage=DDS-4
+status storage=DDS-4
+sleep 1
+status storage=DDS-4
+status storage=DDS-4
+status storage=DDS-4
+status storage=DDS-4
+status storage=DDS-4
+sleep 1
+status storage=DDS-4
+status storage=DDS-4
+status storage=DDS-4
+status storage=DDS-4
+status storage=DDS-4
+sleep 1
+status storage=DDS-4
+status storage=DDS-4
+status storage=DDS-4
+status storage=DDS-4
+status storage=DDS-4
wait
messages
@#
@# now do a restore
@#
@output tmp/log2.out
-restore current all
+restore where=${cwd}/tmp/bacula-restores select all storage=DDS-4 done
+yes
+wait
+messages
+END_OF_DATA
+bin/bacula stop 2>&1 >/dev/null
+#
+# Now do a second backup after making a few changes
+#
+touch ${cwd}/build/src/dird/*.c
+echo "test test" > ${cwd}/build/src/dird/xxx
+bin/bacula start 2>&1 >/dev/null
+bin/bconsole -c bin/bconsole.conf <<END_OF_DATA 2>&1 >/dev/null
+@output /dev/null
+messages
+@output tmp/log1.out
+run job=NightlySave yes
+wait
+messages
+@#
+@# now do a second restore
+@#
+@output tmp/log2.out
+restore where=${cwd}/tmp/bacula-restores select all storage=DDS-4 done
yes
wait
messages
@output
quit
END_OF_DATA
+scripts/check_for_zombie_jobs storage=DDS-4
+
bin/bacula stop 2>&1 >/dev/null
-grep "^Termination: *Backup OK" tmp/log1.out 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
+grep "^ Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
rstat=$?
-diff -r build /tmp/bacula-restores${cwd}/build
+diff -r build tmp/bacula-restores${cwd}/build 2>&1 >/dev/null
if [ $? != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
echo " "
echo " "
- echo " !!!!! Bacula tape test Bacula source failed!!! !!!!! "
- echo " !!!!! Bacula tape test failed!!! !!!!! " >>test.out
+ echo " !!!!! Backup Bacula tape test failed!!! !!!!! "
+ echo " !!!!! Backup Bacula tape test failed!!! !!!!! " >>test.out
echo " "
else
- echo " ===== Bacula tape test Bacula source OK ===== "
- echo " ===== Bacula tape test OK ===== " >>test.out
+ echo " ===== Backup Bacula tape test OK ===== "
+ echo " ===== Backup Bacula tape test OK ===== " >>test.out
scripts/cleanup
fi