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