]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/bscan-test
commit changes
[bacula/bacula] / regress / tests / bscan-test
1 #!/bin/sh
2 #
3 # Run a simple backup of the Bacula build directory but 
4 #   split the archive into two volumes then bscan it
5 #   into the catalog after the backup. It also to a limited
6 #   extent tests the purge volume and delete volume commands.
7 #
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 bscan-test at `date +%R:%S` ==="
24 echo " === Starting bscan-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
32 TestVolume001
33 label storage=File1
34 TestVolume002
35 update Volume=TestVolume001 MaxVolBytes=3000000
36 run job=NightlySave storage=File1
37 yes
38 wait
39 messages
40 @$out /dev/null
41 @#
42 @# now purge the Volume
43 @#
44 purge volume=TestVolume001
45 purge volume=TestVolume002
46 delete volume=TestVolume001
47 yes
48 delete volume=TestVolume002
49 yes
50 messages
51 quit
52 END_OF_DATA
53
54 # run backup
55 if test "$debug" -eq 1 ; then
56   bin/bacula start
57   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
58 else
59   bin/bacula start 2>&1 >/dev/null
60   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
61 fi
62
63 scripts/check_for_zombie_jobs storage=File1
64 bin/bacula stop 2>&1 >/dev/null
65 echo "volume=TestVolume001|TestVolume002" >tmp/bscan.bsr
66
67 if test "$debug" -eq 1 ; then
68   bin/bscan -w working -m -s -v -b tmp/bscan.bsr -c bin/bacula-sd.conf ${cwd}/tmp
69 else
70   bin/bscan -w working -m -s -v -b tmp/bscan.bsr -c bin/bacula-sd.conf ${cwd}/tmp 2>&1 >/dev/null
71 fi
72
73 cat <<END_OF_DATA >tmp/bconcmds
74 @$out /dev/null
75 messages
76 @$out tmp/log2.out
77 @# 
78 @# now do a restore
79 @#
80 @#setdebug level=400 storage=File1
81 restore bootstrap=${cwd}/tmp/kern.bsr where=${cwd}/tmp/bacula-restores select all storage=File1 done
82 yes
83 wait
84 messages
85 @$out
86 quit
87 END_OF_DATA
88
89 # now run restore
90 if test "$debug" -eq 1 ; then
91   bin/bacula start
92   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
93 else
94   bin/bacula start 2>&1 >/dev/null
95   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
96 fi
97
98
99 scripts/check_for_zombie_jobs storage=File1
100 bin/bacula stop 2>&1 >/dev/null
101 grep "^  Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
102 bstat=$?
103 grep "^  Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
104 rstat=$?
105 diff -r build  tmp/bacula-restores${cwd}/build 2>&1 >/dev/null
106 if [ $? != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
107    echo " "
108    echo " "
109    echo "  !!!!! bscan-test Bacula source failed!!! !!!!! "
110    echo "  !!!!! bscan-test failed!!! !!!!! " >>test.out
111    if [ $bstat != 0 -o $rstat != 0 ] ; then
112       echo "  !!!!! Bad Job termination status     !!!!! "
113       echo "  !!!!! Bad Job termination status     !!!!! " >>test.out
114    else
115       echo "  !!!!! Restored files differ          !!!!! "
116       echo "  !!!!! Restored files differ          !!!!! " >>test.out
117    fi
118    echo " "
119 else
120    echo "  ===== bscan-test Bacula source OK ===== "
121    echo "  ===== bscan-test OK ===== " >>test.out
122 #  scripts/cleanup
123 fi