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