7 # Run a accurate backup of the Bacula build directory
11 TestName="accurate-test"
17 /bin/cp -f scripts/bacula-dir.conf.accurate bin/bacula-dir.conf
18 sed s/all,/all,saved,/ bin/bacula-fd.conf > tmp/1
19 cp tmp/1 bin/bacula-fd.conf
21 change_jobname Client1 $JobName
24 echo "##############################################" >> ${cwd}/tmp/log1.out
25 echo "$*" >> ${cwd}/tmp/log1.out
26 echo "##############################################" >> ${cwd}/tmp/log2.out
27 echo "$*" >> ${cwd}/tmp/log2.out
31 rm -rf ${cwd}/build/accurate.new
32 rm -rf ${cwd}/build/accurate
36 mkdir ${cwd}/build/accurate
37 mkdir ${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
52 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
55 label volume=TestVolume001 storage=File pool=Default
61 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
62 @$out ${cwd}/tmp/log1.out
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
79 ################################################################
80 p First : We just run full and restore to compare if all is ok
81 ################################################################
84 check_for_zombie_jobs storage=File
89 rm -rf ${cwd}/tmp/bacula-restores
91 ################################################################
92 p Now do a second backup after making few changes
93 ################################################################
94 rm ${cwd}/build/accurate/xxx # delete a file
95 rm ${cwd}/build/accurate/dirtest/hello
98 check_for_zombie_jobs storage=File
102 check_files_written ${cwd}/tmp/log1.out 4
104 rm -rf ${cwd}/tmp/bacula-restores
106 ################################################################
107 p Now do a third backup after making few changes
108 ################################################################
109 rm ${cwd}/build/accurate/yyyyyy # delete a file
110 rmdir ${cwd}/build/accurate/dirtest
113 check_for_zombie_jobs storage=File
117 check_files_written ${cwd}/tmp/log1.out 3
119 rm -rf ${cwd}/tmp/bacula-restores
121 ################################################################
122 p Now do a 4 backup after making few changes
123 ################################################################
124 rm ${cwd}/build/accurate/zzzzzz # delete a file
127 check_for_zombie_jobs storage=File
131 check_files_written ${cwd}/tmp/log1.out 2
133 rm -rf ${cwd}/tmp/bacula-restores
135 ################################################################
136 p Now do a 5 backup after making few changes
137 ################################################################
138 rm ${cwd}/build/accurate/zzzzzzzzz
141 check_for_zombie_jobs storage=File
145 check_files_written ${cwd}/tmp/log1.out 2
147 rm -rf ${cwd}/tmp/bacula-restores
149 ################################################################
150 p Now do a backup after making few changes
151 ################################################################
152 touch ${cwd}/build/accurate/aaaaaa
155 check_for_zombie_jobs storage=File
159 check_files_written ${cwd}/tmp/log1.out 2
161 rm -rf ${cwd}/tmp/bacula-restores
163 ################################################################
165 ################################################################
167 ${cwd}/bin/bls -c ${cwd}/bin/bacula-sd.conf -V 'TestVolume001' FileStorage > tmp/bls.out
168 grep -- '----' tmp/bls.out | grep xxx > /dev/null
169 if [ $? != 0 ] ; then
173 ################################################################
174 p Now do a backup after making few changes
175 ################################################################
177 # some files will have disappear, others have their old mtime/ctime
178 mv ${cwd}/build/accurate ${cwd}/build/accurate.new
181 check_for_zombie_jobs storage=File
186 rm -rf ${cwd}/tmp/bacula-restores
188 ################################################################
189 p Now do an other test in differential mode
190 ################################################################
192 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
193 @$out ${cwd}/tmp/log1.out
194 run job=$JobName level=differential yes
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
211 check_for_zombie_jobs storage=File
216 rm -rf ${cwd}/tmp/bacula-restores
218 ################################################################
219 p Now do an other test in differential mode + incremental
220 ################################################################
223 mv ${cwd}/build/accurate.new ${cwd}/build/accurate
225 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
226 @$out ${cwd}/tmp/log1.out
233 @$out ${cwd}/tmp/log2.out
234 setdebug level=10 storage=File
235 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
244 check_for_zombie_jobs storage=File
249 rm -rf ${cwd}/tmp/bacula-restores
251 ################################################################
252 p Now do a backup after making few changes
253 ################################################################
254 rm ${cwd}/build/accurate/aaaaaa
255 touch ${cwd}/build/accurate/bbbbbb
258 check_for_zombie_jobs storage=File
259 check_files_written ${cwd}/tmp/log1.out 3
264 ################################################################
265 p Now do a backup after making few changes
266 ################################################################
267 mv ${cwd}/tmp/bacula-restores ${cwd}/build/accurate/
270 check_for_zombie_jobs storage=File
275 rm -rf ${cwd}/tmp/bacula-restores ${cwd}/build/accurate/bacula-restores
277 ################################################################
279 ################################################################
284 ./drop_bacula_tables >/dev/null 2>&1
285 ./make_bacula_tables >/dev/null 2>&1
286 ./grant_bacula_privileges >/dev/null 2>&1
289 echo "volume=TestVolume001" >tmp/bscan.bsr
293 ${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
295 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
296 @$out ${cwd}/tmp/log1.out
301 @$out ${cwd}/tmp/log2.out
302 setdebug level=10 storage=File
303 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
311 # run bacula with just the restore job
314 check_for_zombie_jobs storage=File
319 rm -rf ${cwd}/tmp/bacula-restores
321 ################################################################
322 p Now do a test with other attributes: owner, gid, rights
323 ################################################################
325 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
326 @$out ${cwd}/tmp/log1.out
327 label volume=TestVolume002 storage=File pool=Default
328 run job=backup_advance yes
334 @$out ${cwd}/tmp/log2.out
335 setdebug level=10 storage=File
336 restore fileset=FS_TESTJOB_ADVANCE where=${cwd}/tmp/bacula-restores select all done
345 check_for_zombie_jobs storage=File
350 rm -rf ${cwd}/tmp/bacula-restores
353 ################################################################
354 p Use the p option for verify
355 ################################################################
357 chmod 400 ${cwd}/build/accurate/yyy
359 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
360 @$out ${cwd}/tmp/log1.out
361 run job=backup_advance yes
367 @$out ${cwd}/tmp/log2.out
368 setdebug level=10 storage=File
369 restore fileset=FS_TESTJOB_ADVANCE where=${cwd}/tmp/bacula-restores select all done
378 check_for_zombie_jobs storage=File
382 check_files_written ${cwd}/tmp/log1.out 1
384 rm -rf ${cwd}/tmp/bacula-restores
386 ################################################################
387 p Test strippath option
388 ################################################################
390 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
391 @$out ${cwd}/tmp/log1.out
392 setdebug level=1 client=$CLIENT
393 run job=backup fileset=FS_TESTJOB2 yes
396 @$out ${cwd}/tmp/log3.out
402 check_for_zombie_jobs storage=File
405 rm -f ${cwd}/build/accurate/yyy
407 check_for_zombie_jobs storage=File
409 jobid=`awk '/ Incr.+backup/ { jobid=$1 } END { print jobid }' ${cwd}/tmp/log3.out`
411 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
412 @$out ${cwd}/tmp/log3.out
413 list files jobid=$jobid
419 grep yyy ${cwd}/tmp/log3.out > /dev/null
420 if [ $? != 0 ] ; then
421 print_debug "Can't find yyy file into 'list files' output (${cwd}/tmp/log3.out)"
425 if grep zzz ${cwd}/tmp/log3.out > /dev/null
427 print_debug "Can't find zzz file into 'list files' output (${cwd}/tmp/log3.out)"