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