]> git.sur5r.net Git - bacula/bacula/blobdiff - regress/tests/restore-by-file-tape
Backport from Bacula Enterprise
[bacula/bacula] / regress / tests / restore-by-file-tape
index 858c271bfecfb61fbcaca95063aa250094ecd40c..07dda9addd9deb1161888168f1dad0d99380400c 100755 (executable)
@@ -1,4 +1,9 @@
 #!/bin/sh
+#
+# Copyright (C) 2000-2015 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+
 #
 # Run a simple backup of the Bacula build directory 
 #   to a tape where the maximum tape file size is set to 1M
 #   file size to 1M, it runs very slow. There are about 64 files that
 #   are created during each of the two backups.
 #
-cwd=`pwd`
+TestName="restore-by-file-tape"
+JobName=restorebyfile
+. scripts/functions
+
+require_tape_drive
+
 scripts/copy-tape-confs
 scripts/cleanup-tape
-echo "${cwd}/build" >/tmp/file-list
-sed s%\^%${cwd}% ${cwd}/scripts/flist >${cwd}/tmp/restore2-list
+
+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
-@output /dev/null
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@$out /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=tape volume=TestVolume001 slot=0 pool=Default
+run job=$JobName level=Full yes
 wait
 messages
 @# 
 @# now do a restore
 @#
-@output tmp/log2.out
-restore where=${cwd}/tmp/bacula-restores storage=DDS-4 file=<${cwd}/tmp/restore2-list
+@$out   ${cwd}/tmp/log2.out
+restore where=${cwd}/tmp/bacula-restores storage=tape file=<${cwd}/tmp/restore2-list
 yes
 wait
 messages
-@output
 quit
 END_OF_DATA
+
+run_bacula
+check_for_zombie_jobs storage=tape
+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
-@output /dev/null
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@$out /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
@@ -92,29 +82,26 @@ restore where=${cwd}/tmp/bacula-restores
 yes
 wait
 messages
-@output
 quit
 END_OF_DATA
-scripts/check_for_zombie_jobs storage=DDS-4
-bin/bacula stop 2>&1 >/dev/null
+
+#
+# Bacula was stopped, but we must restart it to
+#  test appending to a previously written tape
+#
+run_bacula
+check_for_zombie_jobs storage=tape
+stop_bacula
+
+check_two_logs
+
+scripts/check_for_zombie_jobs storage=tape
+stop_bacula
 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 " "
-else
-   echo "  ===== restore-by-file-tape test Bacula source OK ===== "
-   echo "  ===== restore-by-file-tape test OK ===== " >>test.out
-#  scripts/cleanup
-fi
+
+end_test