3 # Run a backup of the Bacula build directory on two Volumes
4 # then copy it to another device.
6 # This script uses the virtual disk autochanger and migration scripts
8 TestName="copy-volume-test"
14 scripts/copy-migration-confs
15 scripts/prepare-disk-changer
16 echo "${cwd}/build" >${cwd}/tmp/file-list
17 #cp ${cwd}/bin/bacula-sd.conf ${cwd}/tmp/1
18 #sed "s%# Maximum File Size% Maximum File Size%" ${cwd}/tmp/1 >${cwd}/bin/bacula-sd.conf
20 change_jobname NightlySave $JobName
21 sed 's/migrate/copy/g' ${cwd}/bin/bacula-dir.conf > ${cwd}/tmp/1
22 sed 's/Migrate/Copy/g' ${cwd}/tmp/1 > ${cwd}/bin/bacula-dir.conf
23 rm -f ${cwd}/build/po/test.po >/dev/null
28 # Note, we first backup into Pool Default,
29 # then Copy into Pool Full.
30 # Pool Default uses Storage=File
31 # Pool Full uses Storage=DiskChanger
33 # Write out bconsole commands
34 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
37 @$out ${cwd}/tmp/log1.out
38 label storage=File volume=FileVolume001 Pool=Default
39 label storage=File volume=FileVolume002 Pool=Scratch
40 update Volume=FileVolume001 MaxVolBytes=3000000 pool=Default
41 label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Scratch drive=0
42 label storage=DiskChanger volume=ChangerVolume002 slot=2 Pool=Scratch drive=0
48 update volume=FileVolume001 VolStatus=Used
49 update volume=FileVolume002 VolStatus=Used
53 @$out ${cwd}/tmp/log11.out
54 @############################################################
55 @# should copy one job, and the second is empty
56 @############################################################
57 @# setdebug level=11 dir
58 @echo "Run copy-volume Job"
59 @#setdebug level=100 dir
60 run job=copy-volume yes
68 status storage=DiskChanger
78 select * from JobMedia where JobId=1;
81 @$out ${cwd}/tmp/log2.out
82 @############################################################
85 @# Check that copy uses JobId 1,2
86 @# Use File instead of DiskChanger
88 @############################################################
89 restore where=${cwd}/tmp/bacula-restores select storage=DiskChanger
100 check_for_zombie_jobs storage=File
103 # cleanup previous restore
104 rm -rf ${cwd}/tmp/bacula-restores
106 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
107 @############################################################
108 @# Purge File backup, and restore again
110 @# Check that copy uses other JobId
113 @############################################################
114 @$out ${cwd}/tmp/log3.out
115 purge volume=FileVolume001 yes
116 purge volume=FileVolume002 yes
117 restore where=${cwd}/tmp/bacula-restores select storage=DiskChanger
129 check_for_zombie_jobs storage=DiskChanger
132 # cleanup previous restore
133 rm -rf ${cwd}/tmp/bacula-restores
134 touch ${cwd}/build/po/test.po
136 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
137 @############################################################
138 @# Run a new Incremental, restore melting Copy and Backup
139 @# and copy the new job to Changer
143 @############################################################
144 @$out ${cwd}/tmp/log4.out
148 restore where=${cwd}/tmp/bacula-restores select all
153 update volume=FileVolume001 VolStatus=Used
154 update volume=FileVolume002 VolStatus=Used
155 run job=copy-volume yes
163 check_for_zombie_jobs storage=DiskChanger
168 get_mig_info 1 ${cwd}/tmp/log11.out
170 if [ -z "$RET" -o "$RET" = 0 ]; then
172 print_debug "The first job must have been copied"
175 get_mig_info 2 ${cwd}/tmp/log11.out
177 if [ -n "$RET" ]; then
179 print_debug "The second job has no files, it can't have been copied"
182 JOBID=`awk -F= '/Job queued. JobId/ {if(!f){print $2; f=1;}}' ${cwd}/tmp/log4.out`
183 get_mig_info $JOBID ${cwd}/tmp/log4.out
185 if [ -z "$RET" -o "$RET" = 0 ]; then
187 print_debug "The new incremental job must have been copied"