]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/bsr-opt-test
e2bf556beefc4c97e30f32c07db12eb883d8cbab
[bacula/bacula] / regress / tests / bsr-opt-test
1 #!/bin/sh
2 #
3 # Run a simple backup of the Bacula build directory but 
4 #   split the archive into two volumes, then restore
5 #   files on only one of the volumes and ensure that
6 #   the other volume is not used.  I.e. bsr optimization
7 #   works.
8 #
9 debug=0
10 if test "$debug" -eq 1 ; then
11   out="tee"
12 else
13   out="output"
14 fi
15
16 cwd=`pwd`
17 scripts/copy-test-confs
18 scripts/cleanup
19 echo "${cwd}/build" >/tmp/file-list
20
21 echo " "
22 echo " "
23 echo " === Starting bsr-opt-test at `date +%R:%S` ==="
24 echo " === Starting bsr-opt-test at `date +%R:%S` ===" >working/log
25 echo " "
26
27 cat <<END_OF_DATA >tmp/bconcmds
28 @$out /dev/null
29 messages
30 @$out tmp/log1.out
31 label storage=File1 volume=TestVolume001
32 label storage=File1 volume=TestVolume002
33 update Volume=TestVolume001 MaxVolBytes=3000000
34 run job=NightlySave storage=File1 yes
35 wait
36 messages
37 @# 
38 @# now do a restore
39 @#
40 @$out tmp/log2.out
41 restore bootstrap=${cwd}/working/restore.bsr where=${cwd}/tmp/bacula-restores select storage=File1
42 unmark *
43 cd ${cwd}/build/src/cats
44 mark *
45 ls
46 done
47 yes
48 wait
49 messages
50 @$out
51 quit
52 END_OF_DATA
53
54 if test "$debug" -eq 1 ; then
55   bin/bacula start
56   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
57 else
58   bin/bacula start 2>&1 >/dev/null
59   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
60 fi
61
62 scripts/check_for_zombie_jobs storage=File1
63 bin/bacula stop 2>&1 >/dev/null
64 #
65 # This test is not really reliable. What we want to do is
66 #   to select files on only one Volume, then insure here
67 #   that only one Volume is chosen.
68 #
69 grep TestVolume002 working/restore.bsr 2>&1 >/dev/null
70 bsrstat=$?
71 grep "^  Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
72 bstat=$?
73 grep "^  Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
74 rstat=$?
75 diff -r build/src/cats  tmp/bacula-restores${cwd}/build/src/cats 2>&1 >/dev/null
76 if [ $? != 0 -o $bsrstat != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
77    echo " "
78    echo " "
79    echo "  !!!!! bsr-opt-test Bacula source failed!!! !!!!! "
80    echo "  !!!!! bsr-opt-test failed!!! !!!!! " >>test.out
81    if [ $bstat != 0 -o $rstat != 0 ] ; then
82       echo "  !!!!! Bad Job termination status     !!!!! "
83       echo "  !!!!! Bad Job termination status     !!!!! " >>test.out
84    elif [ $bsrstat != 0 ] ; then
85       echo "  !!!!! Volume selection error         !!!!! "
86       echo "  !!!!! Volume selection error         !!!!! " >>test.out
87    else
88       echo "  !!!!! Restored files differ          !!!!! "
89       echo "  !!!!! Restored files differ          !!!!! " >>test.out
90    fi
91    echo " "
92 else
93    echo "  ===== bsr-opt-test Bacula source OK ===== "
94    echo "  ===== bsr-opt-test OK ===== " >>test.out
95    scripts/cleanup
96 fi