#!/bin/sh # # TODO: # - test bextract # - with strip path # # Run a accurate backup of the Bacula build directory # then restore it. # TestName="accurate-test" JobName=backup . scripts/functions scripts/cleanup copy_test_confs /bin/cp -f scripts/bacula-dir.conf.accurate bin/bacula-dir.conf sed -i s/all,/all,saved,/ bin/bacula-fd.conf change_jobname Client1 $JobName # cleanup rm -rf ${cwd}/build/accurate.new rm -rf ${cwd}/build/accurate # add extra files mkdir ${cwd}/build/accurate echo "test test" > ${cwd}/build/accurate/xxx echo "test test" > ${cwd}/build/accurate/yyy echo "test test" > ${cwd}/build/accurate/zzz echo ${cwd}/build > ${cwd}/tmp/file-list start_test cat <${cwd}/tmp/bconcmds @output /dev/null messages label volume=TestVolume001 storage=File pool=Default messages END_OF_DATA run_bacula cat <${cwd}/tmp/bconcmds @$out ${cwd}/tmp/log1.out run job=$JobName yes wait messages @# @# now do a restore @# @$out ${cwd}/tmp/log2.out restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done yes wait messages @$out quit END_OF_DATA ################################################################ # First : We just run full and restore to compare if all is ok ################################################################ run_bconsole check_for_zombie_jobs storage=File check_two_logs check_restore_diff rm -rf ${cwd}/tmp/bacula-restores ################################################################ # Now do a second backup after making few changes ################################################################ rm ${cwd}/build/accurate/xxx # delete a file run_bconsole check_for_zombie_jobs storage=File check_two_logs check_restore_diff rm -rf ${cwd}/tmp/bacula-restores ################################################################ # Check with bls ################################################################ ${cwd}/bin/bls -c ${cwd}/bin/bacula-sd.conf -V 'TestVolume001' FileStorage > tmp/bls.out grep -- '----' tmp/bls.out | grep xxx > /dev/null if [ $? != 0 ] ; then bstat=2 fi ################################################################ # Now do a third backup after making few changes ################################################################ # some files will have disappear, others have their old mtime/ctime mv ${cwd}/build/accurate ${cwd}/build/accurate.new run_bconsole check_for_zombie_jobs storage=File check_two_logs check_restore_diff rm -rf ${cwd}/tmp/bacula-restores ################################################################ # Now do an other test in differential mode ################################################################ cat <${cwd}/tmp/bconcmds @$out ${cwd}/tmp/log1.out run job=$JobName level=differential yes wait messages @# @# now do a restore @# @$out ${cwd}/tmp/log2.out restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done yes wait messages @$out quit END_OF_DATA run_bconsole check_for_zombie_jobs storage=File check_two_logs check_restore_diff rm -rf ${cwd}/tmp/bacula-restores ################################################################ # Now do an other test in differential mode + incremental ################################################################ # make some changes mv ${cwd}/build/accurate.new ${cwd}/build/accurate cat <${cwd}/tmp/bconcmds @$out ${cwd}/tmp/log1.out run job=$JobName yes wait messages @# @# now do a restore @# @$out ${cwd}/tmp/log2.out restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done yes wait messages @$out quit END_OF_DATA run_bconsole check_for_zombie_jobs storage=File check_two_logs check_restore_diff rm -rf ${cwd}/tmp/bacula-restores ################################################################ # Check with bscan ################################################################ stop_bacula cd ${cwd}/bin ./drop_bacula_tables >/dev/null 2>&1 ./make_bacula_tables >/dev/null 2>&1 ./grant_bacula_privileges >/dev/null 2>&1 cd .. echo "volume=TestVolume001" >tmp/bscan.bsr ${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 cat <${cwd}/tmp/bconcmds @$out ${cwd}/tmp/log1.out messages @# @# now do a restore @# @$out ${cwd}/tmp/log2.out restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done yes wait messages @$out quit END_OF_DATA # run bacula with just the restore job run_bacula check_for_zombie_jobs storage=File check_two_logs check_restore_diff rm -rf ${cwd}/tmp/bacula-restores ################################################################ # Now do a test with other attributes (owner, gid, rights) ################################################################ cat <${cwd}/tmp/bconcmds @$out ${cwd}/tmp/log1.out label volume=TestVolume002 storage=File pool=Default run job=backup_advance yes wait messages @# @# now do a restore @# @$out ${cwd}/tmp/log2.out restore fileset=FS_TESTJOB_ADVANCE where=${cwd}/tmp/bacula-restores select all done yes wait messages @$out quit END_OF_DATA run_bconsole check_for_zombie_jobs storage=File check_two_logs check_restore_diff rm -rf ${cwd}/tmp/bacula-restores ################################################################ # Use the p option for verify ################################################################ chmod 400 ${cwd}/build/accurate/yyy cat <${cwd}/tmp/bconcmds @$out ${cwd}/tmp/log1.out run job=backup_advance yes wait messages @# @# now do a restore @# @$out ${cwd}/tmp/log2.out restore fileset=FS_TESTJOB_ADVANCE where=${cwd}/tmp/bacula-restores select all done yes wait messages @$out quit END_OF_DATA run_bconsole check_for_zombie_jobs storage=File check_two_logs check_restore_diff rm -rf ${cwd}/tmp/bacula-restores grep 'st_mode differ' tmp/log1.out > /dev/null if [ $? != 0 ] ; then bstat=2 fi ################################################################ # Test strippath option ################################################################ cat <${cwd}/tmp/bconcmds @$out ${cwd}/tmp/log1.out setdebug level=1 client run job=backup fileset=FS_TESTJOB2 yes wait messages @$out ${cwd}/tmp/log3.out st dir quit END_OF_DATA run_bconsole check_for_zombie_jobs storage=File # run incremental rm -f ${cwd}/build/accurate/yyy run_bconsole check_for_zombie_jobs storage=File jobid=`awk '/ Incr.+backup/ { jobid=$1 } END { print jobid }' ${cwd}/tmp/log3.out` cat <${cwd}/tmp/bconcmds @$out ${cwd}/tmp/log3.out list files jobid=$jobid quit END_OF_DATA run_bconsole grep yyy ${cwd}/tmp/log3.out > /dev/null if [ $? != 0 ] ; then bstat=2 fi if grep zzz ${cwd}/tmp/log3.out > /dev/null then bstat=2 fi stop_bacula end_test