#!/bin/sh # # Copyright (C) 2000-2015 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS # # # Run a basejob backup of the Bacula build directory # then restore it. # TestName="prune-base-job-test" JobName=backup . scripts/functions $rscripts/cleanup copy_test_confs echo 's/backup_advance/base_backup/' > $tmp/s echo 's/Name = backup/Name = backup; Base = base_backup, backup/' >> $tmp/s sed -f $tmp/s $rscripts/bacula-dir.conf.accurate > $conf/bacula-dir.conf rm -f $tmp/s sed s/all,/all,saved,/ $conf/bacula-fd.conf > tmp/1 cp tmp/1 $conf/bacula-fd.conf change_jobname BackupClient1 $JobName dircfg=$conf/bacula-dir.conf # modify some attributes in configuration file for the test $bperl -e "add_attribute('$dircfg', 'AutoPrune', 'No', 'Client')" $bperl -e "add_attribute('$dircfg', 'Job Retention', '1s', 'Client')" $bperl -e "add_attribute('$dircfg', 'File', '<$tmp/lst', 'FileSet', 'FS_TESTJOB_ADVANCE')" p() { echo "##############################################" >> ${cwd}/tmp/log1.out echo "$*" >> ${cwd}/tmp/log1.out echo "##############################################" >> ${cwd}/tmp/log2.out echo "$*" >> ${cwd}/tmp/log2.out } echo ${cwd}/bin > ${cwd}/tmp/lst echo ${cwd}/bin > ${cwd}/tmp/file-list 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 ################################################################ p Now do a backup using base backup ################################################################ cat <${cwd}/tmp/bconcmds @$out ${cwd}/tmp/log1.out run job=base_backup level=base yes wait messages update volume=TestVolume001 volstatus=Used END_OF_DATA run_bconsole cat <${cwd}/tmp/bconcmds @$out $tmp/log4.out label volume=TestVolume002 storage=File pool=Default run job=backup level=full yes wait messages @exec "touch $cwd/build/po/fr.po" run job=backup level=incremental yes wait messages run job=backup level=differential yes wait messages @# should be empty run job=backup level=incremental yes wait messages @$out $tmp/log2.out @# @# now do a restore @# restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done yes wait messages quit END_OF_DATA run_bconsole check_for_zombie_jobs storage=File check_two_logs check_restore_diff export bstat dstat estat cat <${cwd}/tmp/bconcmds @$out ${cwd}/tmp/log4.out @exec "touch $cwd/build/po/fr.po" run job=backup level=incremental yes wait messages @$out $tmp/log10.out sql SELECT count(*) FROM BaseFiles; list jobs prune jobs yes list jobs @$out $tmp/log1.out @################################################################ @# This full job will force the purge of the previous one run job=backup level=full yes wait messages @$out $tmp/log11.out list jobs prune jobs yes list jobs @$out $tmp/log1.out @################################################################ @# This base job will replace the first one after the next full replacement run job=base_backup level=base yes wait messages @$out $tmp/log1.out @################################################################ @# This full job will force the purge of the previous one run job=backup level=full yes wait messages @$out $tmp/log13.out list jobs prune jobs yes list jobs @$out $tmp/log1.out @################################################################ @# see with two base jobs (base_backup and backup) run job=backup level=base yes wait messages @exec "touch $cwd/bin/bacula-dir.conf" run job=base_backup level=base yes wait messages list jobs run job=backup level=full yes wait messages list jobs @$out $tmp/log14.out list jobs prune jobs yes list jobs END_OF_DATA run_bconsole # Now we will verify that the pruning code is working as expected. Each time, # we run 'list jobs', 'prune', 'list jobs'. check_prune_list ensures that jobids # in argument are present in the first 'list jobs', the 'prune' command deletes # them (same number), and checks that the last 'list jobs' doesn't contain them # anymore. See scripts/functions.pm for details. # B F I D I0 R I -> B F D I $bperl -e "check_prune_list('$tmp/log10.out', 3,5,6)" estat=$(($estat + $?)) # B F D I F -> B F $bperl -e "check_prune_list('$tmp/log11.out', 2,4,7)" estat=$(($estat + $?)) # B F B F -> B F $bperl -e "check_prune_list('$tmp/log13.out',1,8)" estat=$(($estat + $?)) # B F B B F -> B B F $bperl -e "check_prune_list('$tmp/log14.out',9,10)" estat=$(($estat + $?)) stop_bacula end_test