#!/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
+cd bin
+./drop_bacula_tables >/dev/null 2>&1
+./make_bacula_tables >/dev/null 2>&1
+./grant_bacula_privileges 2>&1 >/dev/null
+cd ..
echo " "
echo " "
@# now do a restore
@#
@output tmp/log2.out
-restore where=${cwd}/tmp/bacula-restores select all
+restore where=${cwd}/tmp/bacula-restores select all storage=DDS-4 done
+yes
+wait
+messages
+@#
+@# Now do a second backup
+@#
+@output /dev/null
+messages
+@output tmp/log1.out
+label storage=DDS-4 volume=TestVolume001 slot=0
+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
bstat=$?