#!/bin/sh # # This script uses the virtual disk autochanger # TestName="multi-storage-test" JobName=backup . scripts/functions scripts/cleanup scripts/copy-2disk-confs scripts/prepare-disk-changer # create a new bacula-sd.confs for i in 2 3 4; do perl -ne "\$i='$i';\$tmp='$tmp';"' if (/SDPort = /) { $_ =~ s/(\d+)/1810$i/} if (/Name = /) { $_ =~ s/FileStorage/FileStorage$i/} if (/mediatype = /) { $_ =~ s/FileMedia/FileMedia$1/} if (/WorkingDirectory/) { $_ =~ s:working:tmp/$i:} if (/Pid Directory/) { $_ =~ s:working:tmp/$i:} if (/(Archive|Changer) Device/) { $_ =~ s:$tmp:$tmp/$i:} print; ' $conf/bacula-sd.conf > $conf/bacula-sd$i.conf mkdir -p ${working}$i sed "s/bacula-sd.conf/bacula-sd${i}.conf/" $scripts/bacula-ctl-sd \ > $tmp/bacula-ctl-sd$i chmod +x $tmp/bacula-ctl-sd$i mkdir -p $tmp/$i done # Patch up bacula-dir.conf perl -ne ' if (/^Storage {/) { $in=1; $nb++; } if (/^}/) { $in=0 } if (/SDPort = (\d+)/ && $in) {if ($nb == 2) { $_ = " SDPort = 18102\n"; }} if (/SDPort = (\d+)/ && $in) {if ($nb == 3) { $_ = " SDPort = 18103\n"; }} if (/SDPort = (\d+)/ && $in) {if ($nb == 4) { $_ = " SDPort = 18104\n"; }} print; ' $conf/bacula-dir.conf > $tmp/1 cp $tmp/1 $conf/bacula-dir.conf disable_pluguins echo "${cwd}/build" >${cwd}/tmp/file-list change_jobname $JobName start_test # Write out bconsole commands cat <${cwd}/tmp/bconcmds @out /dev/null messages @$out ${cwd}/tmp/log1.out label storage=tape volume=TestVolume001 Pool=Default slot=1 drive=0 label storage=File volume=TestVolume002 Pool=Default label storage=File2 volume=File2-Vol001 Pool=Default label storage=File3 volume=File3-Vol001 Pool=Default label storage=File4 volume=File4-Vol001 Pool=Default run job=$JobName storage=tape yes wait messages run job=$JobName storage=File yes wait messages run job=$JobName storage=File2 yes wait messages run job=$JobName storage=File3 yes wait messages run job=$JobName storage=File4 yes wait messages quit END_OF_DATA # Start SDs for sd in 2 3 4; do $tmp/bacula-ctl-sd$sd start &> /dev/null done run_bacula echo "ficheriro1.txt" >${cwd}/build/po/ficheriro1.txt echo "ficheriro2.txt" >${cwd}/build/po/ficheriro2.txt cat <${cwd}/tmp/bconcmds @out /dev/null messages @$out ${cwd}/tmp/log1.out @# Force Incremental on the second Volume run level=Incremental storage=File job=$JobName yes wait messages run level=Incremental storage=File2 job=$JobName yes wait messages run level=Incremental storage=File3 job=$JobName yes wait messages run level=Incremental storage=File4 job=$JobName yes wait messages @# @# now do a restore @# @$out ${cwd}/tmp/log2.out setdebug trace=1 level=110 client setdebug trace=1 level=110 director restore where=${cwd}/tmp/bacula-restores select all done yes wait messages show storage sql select * FROM Storage; select VolumeName, Name, StorageId, MediaType FROM Media JOIN Storage USING (StorageId); quit END_OF_DATA run_bconsole check_for_zombie_jobs storage=File check_for_zombie_jobs storage=tape stop_bacula for sd in 2 3 4; do $tmp/bacula-ctl-sd$sd stop &> /dev/null done check_two_logs check_restore_diff end_test