]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/accurate-test
Upgrades
[bacula/bacula] / regress / tests / accurate-test
1 #!/bin/sh
2 #
3 # TODO:
4 #  - test bextract
5 #  - with strip path 
6 #
7 # Run a accurate backup of the Bacula build directory
8 #   then restore it.
9 #
10 TestName="accurate-test"
11 JobName=backup
12 . scripts/functions
13 scripts/cleanup
14
15 copy_test_confs
16 /bin/cp -f scripts/bacula-dir.conf.accurate bin/bacula-dir.conf
17 sed s/all,/all,saved,/ bin/bacula-fd.conf > tmp/1
18 cp tmp/1 bin/bacula-fd.conf
19
20 change_jobname Client1 $JobName
21
22 # cleanup
23 rm -rf ${cwd}/build/accurate.new
24 rm -rf ${cwd}/build/accurate
25
26
27 # add extra files
28 mkdir ${cwd}/build/accurate
29 echo "test test" > ${cwd}/build/accurate/xxx
30 echo "test test" > ${cwd}/build/accurate/yyy
31 echo "test test" > ${cwd}/build/accurate/zzz
32 echo "test test" > ${cwd}/build/accurate/zzzzzz
33 echo "test test" > ${cwd}/build/accurate/xxxxxx
34 echo "test test" > ${cwd}/build/accurate/yyyyyy
35 echo "test test" > ${cwd}/build/accurate/xxxxxxxxx
36 echo "test test" > ${cwd}/build/accurate/yyyyyyyyy
37 echo "test test" > ${cwd}/build/accurate/zzzzzzzzz
38 echo ${cwd}/build > ${cwd}/tmp/file-list
39
40 start_test
41
42 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
43 @output /dev/null
44 messages
45 label volume=TestVolume001 storage=File pool=Default
46 messages
47 END_OF_DATA
48
49 run_bacula
50
51 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
52 @$out ${cwd}/tmp/log1.out
53 run job=$JobName yes
54 wait
55 messages
56 @# 
57 @# now do a restore
58 @#
59 @$out ${cwd}/tmp/log2.out  
60 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
61 yes
62 wait
63 messages
64 @$out
65 quit
66 END_OF_DATA
67
68 ################################################################
69 # First :  We just run full and restore to compare if all is ok
70 ################################################################
71
72 run_bconsole
73 check_for_zombie_jobs storage=File
74
75 check_two_logs
76 check_restore_diff
77
78 rm -rf ${cwd}/tmp/bacula-restores
79
80 ################################################################
81 # Now do a second backup after making few changes
82 ################################################################
83 rm ${cwd}/build/accurate/xxx  # delete a file
84
85 run_bconsole
86 check_for_zombie_jobs storage=File
87
88 check_two_logs
89 check_restore_diff
90
91 rm -rf ${cwd}/tmp/bacula-restores
92
93 ################################################################
94 # Now do a third backup after making few changes
95 ################################################################
96 rm ${cwd}/build/accurate/yyyyyy  # delete a file
97
98 run_bconsole
99 check_for_zombie_jobs storage=File
100
101 check_two_logs
102 check_restore_diff
103
104 rm -rf ${cwd}/tmp/bacula-restores
105
106 ################################################################
107 # Now do a 4 backup after making few changes
108 ################################################################
109 rm ${cwd}/build/accurate/zzzzzz  # delete a file
110
111 run_bconsole
112 check_for_zombie_jobs storage=File
113
114 check_two_logs
115 check_restore_diff
116
117 rm -rf ${cwd}/tmp/bacula-restores
118
119 ################################################################
120 # Now do a 5 backup after making few changes
121 ################################################################
122 rm ${cwd}/build/accurate/zzzzzzzzz
123
124 run_bconsole
125 check_for_zombie_jobs storage=File
126
127 check_two_logs
128 check_restore_diff
129
130 rm -rf ${cwd}/tmp/bacula-restores
131
132 ################################################################
133 # Now do a backup after making few changes
134 ################################################################
135 touch ${cwd}/build/accurate/aaaaaa
136
137 run_bconsole
138 check_for_zombie_jobs storage=File
139
140 check_two_logs
141 check_restore_diff
142
143 rm -rf ${cwd}/tmp/bacula-restores
144
145 ################################################################
146 # Check with bls
147 ################################################################
148
149 ${cwd}/bin/bls -c ${cwd}/bin/bacula-sd.conf -V 'TestVolume001' FileStorage > tmp/bls.out
150 grep -- '----' tmp/bls.out | grep xxx > /dev/null
151 if [ $? != 0 ] ; then
152     bstat=2
153 fi
154
155 ################################################################
156 # Now do a backup after making few changes
157 ################################################################
158
159 # some files will have disappear, others have their old mtime/ctime
160 mv ${cwd}/build/accurate ${cwd}/build/accurate.new
161
162 run_bconsole
163 check_for_zombie_jobs storage=File
164
165 check_two_logs
166 check_restore_diff
167
168 rm -rf ${cwd}/tmp/bacula-restores
169
170 ################################################################
171 # Now do an other test in differential mode
172 ################################################################
173
174 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
175 @$out ${cwd}/tmp/log1.out
176 run job=$JobName level=differential yes
177 wait
178 messages
179 @# 
180 @# now do a restore
181 @#
182 @$out ${cwd}/tmp/log2.out  
183 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
184 yes
185 wait
186 messages
187 @$out
188 quit
189 END_OF_DATA
190
191 run_bconsole
192 check_for_zombie_jobs storage=File
193
194 check_two_logs
195 check_restore_diff
196
197 rm -rf ${cwd}/tmp/bacula-restores
198
199 ################################################################
200 # Now do an other test in differential mode + incremental
201 ################################################################
202
203 # make some changes
204 mv ${cwd}/build/accurate.new ${cwd}/build/accurate
205
206 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
207 @$out ${cwd}/tmp/log1.out
208 run job=$JobName yes
209 wait
210 messages
211 @# 
212 @# now do a restore
213 @#
214 @$out ${cwd}/tmp/log2.out  
215 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
216 yes
217 wait
218 messages
219 @$out
220 quit
221 END_OF_DATA
222
223 run_bconsole
224 check_for_zombie_jobs storage=File
225
226 check_two_logs
227 check_restore_diff
228
229 rm -rf ${cwd}/tmp/bacula-restores
230
231 ################################################################
232 # Now do a backup after making few changes
233 ################################################################
234 rm ${cwd}/build/accurate/aaaaaa
235 touch ${cwd}/build/accurate/bbbbbb
236
237 run_bconsole
238 check_for_zombie_jobs storage=File
239
240 check_two_logs
241 check_restore_diff
242
243 ################################################################
244 # Now do a backup after making few changes
245 ################################################################
246 mv ${cwd}/tmp/bacula-restores ${cwd}/build/accurate/
247
248 run_bconsole
249 check_for_zombie_jobs storage=File
250
251 check_two_logs
252 check_restore_diff
253
254 rm -rf ${cwd}/tmp/bacula-restores ${cwd}/build/accurate/bacula-restores
255
256 ################################################################
257 # Check with bscan
258 ################################################################
259
260 stop_bacula
261
262 cd ${cwd}/bin
263   ./drop_bacula_tables      >/dev/null 2>&1
264   ./make_bacula_tables      >/dev/null 2>&1
265   ./grant_bacula_privileges >/dev/null 2>&1
266 cd ..
267
268 echo "volume=TestVolume001" >tmp/bscan.bsr
269
270 bscan_libdbi
271
272 ${cwd}/bin/bscan -c ${cwd}/bin/bacula-sd.conf $BSCANLIBDBI -n regress -u regress -m -s -b tmp/bscan.bsr FileStorage 2>&1 > ${cwd}/tmp/bscan.log
273
274 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
275 @$out ${cwd}/tmp/log1.out
276 messages
277 @# 
278 @# now do a restore
279 @#
280 @$out ${cwd}/tmp/log2.out  
281 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
282 yes
283 wait
284 messages
285 @$out
286 quit
287 END_OF_DATA
288
289 # run bacula with just the restore job
290 run_bacula
291
292 check_for_zombie_jobs storage=File
293
294 check_two_logs
295 check_restore_diff
296
297 rm -rf ${cwd}/tmp/bacula-restores
298
299 ################################################################
300 # Now do a test with other attributes (owner, gid, rights)
301 ################################################################
302
303 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
304 @$out ${cwd}/tmp/log1.out
305 label volume=TestVolume002 storage=File pool=Default
306 run job=backup_advance yes
307 wait
308 messages
309 @# 
310 @# now do a restore
311 @#
312 @$out ${cwd}/tmp/log2.out  
313 restore fileset=FS_TESTJOB_ADVANCE where=${cwd}/tmp/bacula-restores select all done
314 yes
315 wait
316 messages
317 @$out
318 quit
319 END_OF_DATA
320
321 run_bconsole
322 check_for_zombie_jobs storage=File
323
324 check_two_logs
325 check_restore_diff
326
327 rm -rf ${cwd}/tmp/bacula-restores
328
329
330 ################################################################
331 # Use the p option for verify
332 ################################################################
333
334 chmod 400 ${cwd}/build/accurate/yyy
335
336 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
337 @$out ${cwd}/tmp/log1.out
338 run job=backup_advance yes
339 wait
340 messages
341 @# 
342 @# now do a restore
343 @#
344 @$out ${cwd}/tmp/log2.out  
345 restore fileset=FS_TESTJOB_ADVANCE where=${cwd}/tmp/bacula-restores select all done
346 yes
347 wait
348 messages
349 @$out
350 quit
351 END_OF_DATA
352
353 run_bconsole
354 check_for_zombie_jobs storage=File
355
356 check_two_logs
357 check_restore_diff
358
359 rm -rf ${cwd}/tmp/bacula-restores
360
361 ################################################################
362 # Test strippath option
363 ################################################################
364
365 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
366 @$out ${cwd}/tmp/log1.out
367 setdebug  level=1 client
368 run job=backup fileset=FS_TESTJOB2 yes
369 wait
370 messages
371 @$out ${cwd}/tmp/log3.out
372 st dir
373 quit
374 END_OF_DATA
375
376 run_bconsole
377 check_for_zombie_jobs storage=File
378
379 # run incremental
380 rm -f ${cwd}/build/accurate/yyy
381 run_bconsole
382 check_for_zombie_jobs storage=File
383
384 jobid=`awk '/ Incr.+backup/ { jobid=$1 } END { print jobid }' ${cwd}/tmp/log3.out`
385
386 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
387 @$out ${cwd}/tmp/log3.out
388 list files jobid=$jobid
389 quit
390 END_OF_DATA
391
392 run_bconsole
393
394 grep yyy ${cwd}/tmp/log3.out > /dev/null
395 if [ $? != 0 ] ; then
396     print_debug "Can't find xxx file into 'list files' output (${cwd}/tmp/log3.out)"
397     dstat=2
398 fi
399
400 if grep zzz ${cwd}/tmp/log3.out > /dev/null
401 then
402     print_debug "Can't find zzz file into 'list files' output (${cwd}/tmp/log3.out)"
403     dstat=2
404 fi
405
406 stop_bacula
407 end_test
408