]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/accurate-test
Fix backup-bacula regression
[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     print_debug "ERROR: Should find deleted files into $tmp/bls.out"
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 quit
207 END_OF_DATA
208
209 run_bconsole
210 check_for_zombie_jobs storage=File
211
212 check_two_logs
213 check_restore_diff
214
215 rm -rf ${cwd}/tmp/bacula-restores
216
217 ################################################################
218 p Now do an other test in differential mode + incremental
219 ################################################################
220
221 # make some changes
222 mv ${cwd}/build/accurate.new ${cwd}/build/accurate
223
224 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
225 @$out ${cwd}/tmp/log1.out
226 run job=$JobName yes
227 wait
228 messages
229 @# 
230 @# now do a restore
231 @#
232 @$out ${cwd}/tmp/log2.out  
233 setdebug level=10 storage=File
234 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
235 yes
236 wait
237 messages
238 quit
239 END_OF_DATA
240
241 run_bconsole
242 check_for_zombie_jobs storage=File
243
244 check_two_logs
245 check_restore_diff
246
247 rm -rf ${cwd}/tmp/bacula-restores
248
249 ################################################################
250 p Now do a backup after making few changes
251 ################################################################
252 rm ${cwd}/build/accurate/aaaaaa
253 touch ${cwd}/build/accurate/bbbbbb
254
255 run_bconsole
256 check_for_zombie_jobs storage=File
257 check_files_written ${cwd}/tmp/log1.out 3
258
259 check_two_logs
260 check_restore_diff
261
262 ################################################################
263 p Now do a backup after making few changes
264 ################################################################
265 mv ${cwd}/tmp/bacula-restores ${cwd}/build/accurate/
266
267 run_bconsole
268 check_for_zombie_jobs storage=File
269
270 check_two_logs
271 check_restore_diff
272
273 rm -rf ${cwd}/tmp/bacula-restores ${cwd}/build/accurate/bacula-restores
274
275 ################################################################
276 p Check with bscan
277 ################################################################
278
279 stop_bacula
280
281 cd $bin
282   ./drop_bacula_tables      >/dev/null 2>&1
283   ./make_bacula_tables      >/dev/null 2>&1
284   ./grant_bacula_privileges >/dev/null 2>&1
285 cd ..
286
287 echo "volume=TestVolume001" >tmp/bscan.bsr
288
289 bscan_libdbi
290
291 $bin/bscan -c $conf/bacula-sd.conf $BSCANLIBDBI -n regress -u regress -m -s -b $tmp/bscan.bsr FileStorage 2>&1 > $tmp/bscan.log
292
293 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
294 @$out ${cwd}/tmp/log1.out
295 messages
296 @# 
297 @# now do a restore after bscan
298 @#
299 @$out ${cwd}/tmp/log2.out  
300 setdebug level=10 storage=File
301 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
302 yes
303 wait
304 messages
305 quit
306 END_OF_DATA
307
308 # run bacula with just the restore job
309 run_bacula
310
311 check_for_zombie_jobs storage=File
312
313 check_two_logs
314 check_restore_diff
315
316 rm -rf ${cwd}/tmp/bacula-restores
317
318 ################################################################
319 p Now do a test with other attributes: owner, gid, rights
320 ################################################################
321
322 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
323 @$out ${cwd}/tmp/log1.out
324 label volume=TestVolume002 storage=File pool=Default
325 run job=backup_advance yes
326 wait
327 messages
328 @# 
329 @# now do a restore
330 @#
331 @$out ${cwd}/tmp/log2.out  
332 setdebug level=10 storage=File
333 restore fileset=FS_TESTJOB_ADVANCE where=${cwd}/tmp/bacula-restores select all done
334 yes
335 wait
336 messages
337 quit
338 END_OF_DATA
339
340 run_bconsole
341 check_for_zombie_jobs storage=File
342
343 check_two_logs
344 check_restore_diff
345
346 rm -rf ${cwd}/tmp/bacula-restores
347
348
349 ################################################################
350 p Use the p option for verify
351 ################################################################
352
353 chmod 400 ${cwd}/build/accurate/yyy
354
355 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
356 @$out ${cwd}/tmp/log1.out
357 run job=backup_advance yes
358 wait
359 messages
360 @# 
361 @# now do a restore
362 @#
363 @$out ${cwd}/tmp/log2.out  
364 setdebug level=10 storage=File
365 restore fileset=FS_TESTJOB_ADVANCE where=${cwd}/tmp/bacula-restores select all done
366 yes
367 wait
368 messages
369 quit
370 END_OF_DATA
371
372 run_bconsole
373 check_for_zombie_jobs storage=File
374
375 check_two_logs
376 check_restore_diff
377 check_files_written ${cwd}/tmp/log1.out 1
378
379 rm -rf ${cwd}/tmp/bacula-restores
380
381 ################################################################
382 p Test strippath option
383 ################################################################
384
385 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
386 @$out ${cwd}/tmp/log1.out
387 setdebug  level=1 client=$CLIENT
388 run job=backup fileset=FS_TESTJOB2 yes
389 wait
390 messages
391 @$out ${cwd}/tmp/log3.out
392 st dir
393 quit
394 END_OF_DATA
395
396 run_bconsole
397 check_for_zombie_jobs storage=File
398
399 # run incremental
400 rm -f ${cwd}/build/accurate/yyy
401 run_bconsole
402 check_for_zombie_jobs storage=File
403
404 jobid=`awk '/ Incr.+backup/ { jobid=$1 } END { print jobid }' ${cwd}/tmp/log3.out`
405
406 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
407 @$out ${cwd}/tmp/log3.out
408 list files jobid=$jobid
409 quit
410 END_OF_DATA
411
412 run_bconsole
413
414 grep yyy ${cwd}/tmp/log3.out > /dev/null
415 if [ $? != 0 ] ; then
416     print_debug "ERROR: Can't find yyy file into 'list files' output (${cwd}/tmp/log3.out)"
417     dstat=2
418 fi
419
420 grep zzz ${cwd}/tmp/log3.out > /dev/null
421 if [ $? = 0 ] ; then
422     print_debug "ERROR: Should not find zzz file into 'list files' output (${cwd}/tmp/log3.out)"
423     dstat=2
424 fi
425
426 stop_bacula
427 end_test