#!/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
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
+yes
+wait
+messages
@output
quit
END_OF_DATA
quit
END_OF_DATA
bin/bacula stop 2>&1 >/dev/null
-grep TestVolume001 working/restore.bsr
+grep TestVolume001 working/restore.bsr 2>&1 >/dev/null
bsrstat=$?
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/src/cats tmp/bacula-restores${cwd}/build/src/cats 2>&1 >/dev/null
-if [ $? != 0 -o $bsrstat != 1 -o $bstat != 0 -o $rstat != 0 ] ; then
+if [ $? != 0 -o $bsrstat != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
echo " "
echo " "
echo " !!!!! bsr-opt-test Bacula source failed!!! !!!!! "
TestVolume001
label storage=File1
TestVolume002
-update Volume=TestVolume001
-6
-100000000
+update Volume=TestVolume001 MaxVolBytes=100000000
@#50000000
-10
+12
run job=NightlySave level=Full Storage=File1
yes
run job=NightlySave level=Full Storage=File1
@# now do a restore
@#
@output tmp/log2.out
-restore where=${cwd}/tmp/bacula-restores
-5
-done
+restore where=${cwd}/tmp/bacula-restores select all
yes
wait
messages