]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/bscan-tape
5225103a89ad3ea51dbade59198d2422ba794779
[bacula/bacula] / regress / tests / bscan-tape
1 #!/bin/sh
2 #
3 # Run a simple backup of the Bacula build directory using the compressed option
4 #   then backup four times, each with incremental then 
5 #   do a bscan and restore.
6 #   It should require at least 4 different bsrs.
7 #
8 debug=0
9 if test "$debug" -eq 1 ; then
10   out="tee"
11 else
12   out="output"
13 fi
14
15 cwd=`pwd`
16 scripts/copy-tape-confs
17 scripts/cleanup-tape
18 echo "${cwd}/build" >/tmp/file-list
19
20 cp ${cwd}/bin/bacula-sd.conf ${cwd}/tmp/1
21 sed "s%# Maximum File Size%  Maximum File Size%" ${cwd}/tmp/1 >${cwd}/bin/bacula-sd.conf
22
23 echo " "
24 echo " "
25 echo " === Starting bscan-tape at `date +%R:%S` ==="
26 echo " === Starting bscan-tape at `date +%R:%S` ===" >>working/log
27 echo " "
28
29 cat <<END_OF_DATA >tmp/bconcmds
30 @output /dev/null
31 estimate job=NightlySave listing
32 estimate job=NightlySave listing
33 estimate job=NightlySave listing
34 messages
35 @$out tmp/log1.out
36 setdebug level=2 storage=DDS-4
37 label storage=DDS-4 volume=TestVolume001 slot=0 pool=Default
38 run job=NightlySave yes
39 wait
40 run job=NightlySave level=Full yes
41 wait
42 run job=NightlySave level=Full yes
43 wait
44 messages
45 quit
46 END_OF_DATA
47
48 if test "$debug" -eq 1 ; then
49   bin/bacula start
50   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
51 else
52   bin/bacula start 2>&1 >/dev/null
53   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
54 fi
55 scripts/check_for_zombie_jobs storage=DDS-4
56 echo "Backup 1 done"
57 # make some files for the incremental to pick up
58 touch ${cwd}/build/src/dird/*.c ${cwd}/build/src/dird/*.o
59 touch ${cwd}/build/src/lib/*.c ${cwd}/build/src/lib/*.o
60    
61 #
62 # run a second job
63 #
64 cat <<END_OF_DATA >tmp/bconcmds
65 @$out /dev/null
66 messages
67 @$out tmp/log1.out
68 run job=NightlySave level=Incremental yes
69 wait
70 messages
71 quit
72 END_OF_DATA
73 if test "$debug" -eq 1 ; then
74   bin/bacula start
75   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
76 else
77   bin/bacula start 2>&1 >/dev/null
78   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
79 fi
80
81 scripts/check_for_zombie_jobs storage=DDS-4
82 echo "Backup 2 done"
83 touch ${cwd}/build/src/dird/*.c
84 touch ${cwd}/build/src/lib/*.c ${cwd}/build/src/lib/*.o
85 #
86 # run a third job
87 #
88 cat <<END_OF_DATA >tmp/bconcmds
89 @$out /dev/null
90 messages
91 @$out tmp/log1.out
92 run job=NightlySave level=Incremental yes
93 wait
94 messages
95 quit
96 END_OF_DATA
97 if test "$debug" -eq 1 ; then
98   bin/bacula start
99   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
100 else
101   bin/bacula start 2>&1 >/dev/null
102   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
103 fi
104
105 scripts/check_for_zombie_jobs storage=DDS-4
106 echo "Backup 3 done"
107 # make some files for the incremental to pick up
108 touch ${cwd}/build/src/lib/*.c ${cwd}/build/src/lib/*.o
109 #echo "abc" > ${cwd}/build/src/lib/dummy
110 #
111 # run a fourth job
112 #
113
114 cat <<END_OF_DATA >tmp/bconcmds
115 @$out /dev/null
116 messages
117 @$out tmp/log1.out
118 run job=NightlySave level=Incremental yes
119 wait
120 messages
121 quit
122 END_OF_DATA
123 if test "$debug" -eq 1 ; then
124   bin/bacula start
125   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
126 else
127   bin/bacula start 2>&1 >/dev/null
128   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
129 fi
130
131 scripts/check_for_zombie_jobs storage=DDS-4
132 echo "Backup 4 done"
133 #
134 # now drop and recreate the database
135 #
136 cd bin
137 ./drop_bacula_tables >/dev/null 2>&1
138 ./make_bacula_tables >/dev/null 2>&1
139 ./grant_bacula_privileges 2>&1 >/dev/null
140 cd ..
141
142 bin/bacula stop 2>&1 >/dev/null
143 echo "volume=TestVolume001" >tmp/bscan.bsr
144 bin/bscan -w working -m -s -v -b tmp/bscan.bsr -c bin/bacula-sd.conf DDS-4 2>&1 >/dev/null
145 bin/bacula start 2>&1 >/dev/null
146 bin/bconsole -c bin/bconsole.conf <<END_OF_DATA 2>&1 >/dev/null
147 @$out /dev/null
148 messages
149 @$out tmp/log2.out
150 @# 
151 @# now do a restore
152 @#
153 restore where=${cwd}/tmp/bacula-restores select all storage=DDS-4 done
154 yes
155 wait
156 messages
157 @$out
158 quit
159 END_OF_DATA
160 scripts/check_for_zombie_jobs storage=DDS-4
161 rm -f  ${cwd}/build/src/lib/dummy
162 bin/bacula stop 2>&1 >/dev/null
163 grep "^  Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
164 bstat=$?
165 grep "^  Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
166 rstat=$?
167 diff -r build tmp/bacula-restores${cwd}/build 2>&1 >/dev/null
168 if [ $? != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
169    echo " "
170    echo " "
171    echo "  !!!!! bscan-tape Bacula source failed!!! !!!!! "
172    echo "  !!!!! bscan-tape failed!!! !!!!! " >>test.out
173    echo " "
174 else
175    echo "  ===== bscan-tape Bacula source OK ===== "
176    echo "  ===== bscan-tape OK ===== " >>test.out
177 #  scripts/cleanup
178 fi