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