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