7 # Run a accurate backup of the Bacula build directory
11 TestName="accurate-test"
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
21 change_jobname BackupClient1 $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
28 if test "$debug" -eq 1 ; then
29 echo "##############################################"
35 rm -rf ${cwd}/build/accurate.new
36 rm -rf ${cwd}/build/accurate
40 mkdir -p ${cwd}/build/accurate
41 mkdir -p ${cwd}/build/accurate/dirtest
42 echo "test test" > ${cwd}/build/accurate/dirtest/hello
43 echo "test test" > ${cwd}/build/accurate/xxx
44 echo "test test" > ${cwd}/build/accurate/yyy
45 echo "test test" > ${cwd}/build/accurate/zzz
46 echo "test test" > ${cwd}/build/accurate/zzzzzz
47 echo "test test" > ${cwd}/build/accurate/xxxxxx
48 echo "test test" > ${cwd}/build/accurate/yyyyyy
49 echo "test test" > ${cwd}/build/accurate/xxxxxxxxx
50 echo "test test" > ${cwd}/build/accurate/yyyyyyyyy
51 echo "test test" > ${cwd}/build/accurate/zzzzzzzzz
52 echo ${cwd}/build > ${cwd}/tmp/file-list
56 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
59 label volume=TestVolume001 storage=File pool=Default
65 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
66 @$out ${cwd}/tmp/log1.out
73 @$out ${cwd}/tmp/log2.out
74 setdebug level=10 storage=File
75 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
82 ################################################################
83 p First : We just run full and restore to compare if all is ok
84 ################################################################
87 check_for_zombie_jobs storage=File
92 rm -rf ${cwd}/tmp/bacula-restores
94 ################################################################
95 p Now do a second backup after making few changes
96 ################################################################
97 rm ${cwd}/build/accurate/xxx # delete a file
98 rm ${cwd}/build/accurate/dirtest/hello
101 check_for_zombie_jobs storage=File
105 check_files_written ${cwd}/tmp/log1.out 4
107 rm -rf ${cwd}/tmp/bacula-restores
109 ################################################################
110 p Now do a third backup after making few changes
111 ################################################################
112 rm ${cwd}/build/accurate/yyyyyy # delete a file
113 rmdir ${cwd}/build/accurate/dirtest
116 check_for_zombie_jobs storage=File
120 check_files_written ${cwd}/tmp/log1.out 3
122 rm -rf ${cwd}/tmp/bacula-restores
124 ################################################################
125 p Now do a 4 backup after making few changes
126 ################################################################
127 rm ${cwd}/build/accurate/zzzzzz # delete a file
130 check_for_zombie_jobs storage=File
134 check_files_written ${cwd}/tmp/log1.out 2
136 rm -rf ${cwd}/tmp/bacula-restores
138 ################################################################
139 p Now do a 5 backup after making few changes
140 ################################################################
141 rm ${cwd}/build/accurate/zzzzzzzzz
144 check_for_zombie_jobs storage=File
148 check_files_written ${cwd}/tmp/log1.out 2
150 rm -rf ${cwd}/tmp/bacula-restores
152 ################################################################
153 p Now do a backup after making few changes
154 ################################################################
155 touch ${cwd}/build/accurate/aaaaaa
158 check_for_zombie_jobs storage=File
162 check_files_written ${cwd}/tmp/log1.out 2
164 rm -rf ${cwd}/tmp/bacula-restores
166 ################################################################
168 ################################################################
170 $bin/bls -c $conf/bacula-sd.conf -V 'TestVolume001' FileStorage > $tmp/bls.out
171 grep -- '----' $tmp/bls.out | grep xxx > /dev/null
172 if [ $? != 0 ] ; then
173 print_debug "ERROR: Should find deleted files into $tmp/bls.out"
177 ################################################################
178 p Now do a backup after making few changes
179 ################################################################
181 # some files will have disappear, others have their old mtime/ctime
182 mv ${cwd}/build/accurate ${cwd}/build/accurate.new
185 check_for_zombie_jobs storage=File
190 rm -rf ${cwd}/tmp/bacula-restores
192 ################################################################
193 p Now do an other test in differential mode
194 ################################################################
196 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
197 @$out ${cwd}/tmp/log1.out
198 run job=$JobName level=differential yes
204 @$out ${cwd}/tmp/log2.out
205 setdebug level=10 storage=File
206 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
214 check_for_zombie_jobs storage=File
219 rm -rf ${cwd}/tmp/bacula-restores
221 ################################################################
222 p Now do an other test in differential mode + incremental
223 ################################################################
226 mv ${cwd}/build/accurate.new ${cwd}/build/accurate
228 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
229 @$out ${cwd}/tmp/log1.out
236 @$out ${cwd}/tmp/log2.out
237 setdebug level=10 storage=File
238 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
246 check_for_zombie_jobs storage=File
251 rm -rf ${cwd}/tmp/bacula-restores
253 ################################################################
254 p Now do a backup after making few changes
255 ################################################################
256 rm ${cwd}/build/accurate/aaaaaa
257 touch ${cwd}/build/accurate/bbbbbb
260 check_for_zombie_jobs storage=File
261 check_files_written ${cwd}/tmp/log1.out 3
266 ################################################################
267 p Now do a backup after making few changes
268 ################################################################
269 mv ${cwd}/tmp/bacula-restores ${cwd}/build/accurate/
272 check_for_zombie_jobs storage=File
277 rm -rf ${cwd}/tmp/bacula-restores ${cwd}/build/accurate/bacula-restores
279 ################################################################
281 ################################################################
286 ./drop_bacula_tables >/dev/null 2>&1
287 ./make_bacula_tables >/dev/null 2>&1
288 ./grant_bacula_privileges >/dev/null 2>&1
291 echo "volume=TestVolume001" >tmp/bscan.bsr
295 $bin/bscan -c $conf/bacula-sd.conf $BSCANLIBDBI -n "$db_name" -u "$db_user" -m -s -b $tmp/bscan.bsr FileStorage 2>&1 > $tmp/bscan.log
297 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
298 @$out ${cwd}/tmp/log1.out
301 @# now do a restore after bscan
303 @$out ${cwd}/tmp/log2.out
304 setdebug level=10 storage=File
305 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
312 # run bacula with just the restore job
315 check_for_zombie_jobs storage=File
320 rm -rf ${cwd}/tmp/bacula-restores
322 ################################################################
323 p Now do a test with other attributes: owner, gid, rights
324 ################################################################
326 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
327 @$out ${cwd}/tmp/log1.out
328 label volume=TestVolume002 storage=File pool=Default
329 run job=backup_advance yes
335 @$out ${cwd}/tmp/log2.out
336 setdebug level=10 storage=File
337 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
377 check_for_zombie_jobs storage=File
381 check_files_written ${cwd}/tmp/log1.out 1
383 rm -rf ${cwd}/tmp/bacula-restores
385 ################################################################
386 p Test strippath option
387 ################################################################
389 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
390 @$out ${cwd}/tmp/log1.out
391 setdebug level=1 client=$CLIENT
392 run job=backup fileset=FS_TESTJOB2 yes
395 @$out ${cwd}/tmp/log3.out
401 check_for_zombie_jobs storage=File
404 rm -f ${cwd}/build/accurate/yyy
406 check_for_zombie_jobs storage=File
408 jobid=`awk '/ Incr.+backup/ { jobid=$1 } END { print jobid }' ${cwd}/tmp/log3.out`
410 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
411 @$out ${cwd}/tmp/log3.out
412 list files jobid=$jobid
418 grep yyy ${cwd}/tmp/log3.out > /dev/null
419 if [ $? != 0 ] ; then
420 print_debug "ERROR: Can't find yyy file into 'list files' output (${cwd}/tmp/log3.out)"
424 grep zzz ${cwd}/tmp/log3.out > /dev/null
426 print_debug "ERROR: Should not find zzz file into 'list files' output (${cwd}/tmp/log3.out)"