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