3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
12 # Run a accurate backup of the Bacula build directory
16 TestName="accurate-test"
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
26 change_jobname BackupClient1 $JobName
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 "##############################################"
40 rm -rf ${cwd}/build/accurate.new
41 rm -rf ${cwd}/build/accurate
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
61 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
64 label volume=TestVolume001 storage=File pool=Default
70 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
71 @$out ${cwd}/tmp/log1.out
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
87 ################################################################
88 p First : We just run full and restore to compare if all is ok
89 ################################################################
92 check_for_zombie_jobs storage=File
97 rm -rf ${cwd}/tmp/bacula-restores
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
106 check_for_zombie_jobs storage=File
110 check_files_written ${cwd}/tmp/log1.out 4
112 rm -rf ${cwd}/tmp/bacula-restores
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
121 check_for_zombie_jobs storage=File
125 check_files_written ${cwd}/tmp/log1.out 3
127 rm -rf ${cwd}/tmp/bacula-restores
129 ################################################################
130 p Now do a 4 backup after making few changes
131 ################################################################
132 rm ${cwd}/build/accurate/zzzzzz # delete a file
135 check_for_zombie_jobs storage=File
139 check_files_written ${cwd}/tmp/log1.out 2
141 rm -rf ${cwd}/tmp/bacula-restores
143 ################################################################
144 p Now do a 5 backup after making few changes
145 ################################################################
146 rm ${cwd}/build/accurate/zzzzzzzzz
149 check_for_zombie_jobs storage=File
153 check_files_written ${cwd}/tmp/log1.out 2
155 rm -rf ${cwd}/tmp/bacula-restores
157 ################################################################
158 p Now do a backup after making few changes
159 ################################################################
160 touch ${cwd}/build/accurate/aaaaaa
163 check_for_zombie_jobs storage=File
167 check_files_written ${cwd}/tmp/log1.out 2
169 rm -rf ${cwd}/tmp/bacula-restores
171 ################################################################
173 ################################################################
176 ################################################################
177 p Now do a backup after making few changes
178 ################################################################
180 # some files will have disappear, others have their old mtime/ctime
181 mv ${cwd}/build/accurate ${cwd}/build/accurate.new
184 check_for_zombie_jobs storage=File
189 rm -rf ${cwd}/tmp/bacula-restores
191 ################################################################
192 p Now do an other test in differential mode
193 ################################################################
195 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
196 @$out ${cwd}/tmp/log1.out
197 run job=$JobName level=differential yes
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
213 check_for_zombie_jobs storage=File
218 rm -rf ${cwd}/tmp/bacula-restores
220 ################################################################
221 p Now do an other test in differential mode + incremental
222 ################################################################
225 mv ${cwd}/build/accurate.new ${cwd}/build/accurate
227 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
228 @$out ${cwd}/tmp/log1.out
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
245 check_for_zombie_jobs storage=File
250 rm -rf ${cwd}/tmp/bacula-restores
252 ################################################################
253 p Now do a backup after making few changes
254 ################################################################
255 rm ${cwd}/build/accurate/aaaaaa
256 touch ${cwd}/build/accurate/bbbbbb
259 check_for_zombie_jobs storage=File
260 check_files_written ${cwd}/tmp/log1.out 3
265 ################################################################
266 p Now do a backup after making few changes
267 ################################################################
268 mv ${cwd}/tmp/bacula-restores ${cwd}/build/accurate/
271 check_for_zombie_jobs storage=File
276 rm -rf ${cwd}/tmp/bacula-restores
280 ################################################################
281 p Check with bscan -- this takes some time
282 ################################################################
285 ./drop_bacula_tables >/dev/null 2>&1
286 ./make_bacula_tables >/dev/null 2>&1
287 ./grant_bacula_privileges >/dev/null 2>&1
290 echo "volume=TestVolume001" >tmp/bscan.bsr
294 # If the database has a password pass it to bscan
295 if test "x${db_password}" = "x"; then
298 PASSWD="-P ${db_password}"
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
303 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
304 @$out ${cwd}/tmp/log1.out
307 @# now do a restore after bscan
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
318 # run bacula with just the restore job
321 check_for_zombie_jobs storage=File
326 rm -rf ${cwd}/tmp/bacula-restores ${cwd}/build/accurate/bacula-restores
328 ################################################################
329 p Now do a test with other attributes: owner, gid, rights
330 ################################################################
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
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
351 check_for_zombie_jobs storage=File
356 rm -rf ${cwd}/tmp/bacula-restores
359 ################################################################
360 p Use the p option for verify
361 ################################################################
363 chmod 400 ${cwd}/build/accurate/yyy
365 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
366 @$out ${cwd}/tmp/log1.out
367 run job=backup_advance yes
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
383 check_for_zombie_jobs storage=File
387 check_files_written ${cwd}/tmp/log1.out 1
389 rm -rf ${cwd}/tmp/bacula-restores
391 ################################################################
392 p Test strippath option
393 ################################################################
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
401 @$out ${cwd}/tmp/log3.out
407 check_for_zombie_jobs storage=File
410 rm -f ${cwd}/build/accurate/yyy
412 check_for_zombie_jobs storage=File
414 jobid=`awk '/ Incr.+backup/ { jobid=$1 } END { print jobid }' ${cwd}/tmp/log3.out`
416 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
417 @$out ${cwd}/tmp/log3.out
418 list files type=all jobid=$jobid
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)"
430 grep zzz ${cwd}/tmp/log3.out > /dev/null
432 print_debug "ERROR: Should not find zzz file into 'list files' output (${cwd}/tmp/log3.out)"