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