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
101 check_for_zombie_jobs storage=File
104 # cleanup previous restore
105 rm -rf ${cwd}/tmp/bacula-restores
107 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
108 @############################################################
109 @# Purge File backup, and restore again
111 @# Check that copy uses other JobId
114 @############################################################
115 @$out ${cwd}/tmp/log3.out
116 purge volume=FileVolume001 yes
117 purge volume=FileVolume002 yes
118 restore where=${cwd}/tmp/bacula-restores select storage=DiskChanger
130 check_for_zombie_jobs storage=DiskChanger
133 # cleanup previous restore
134 rm -rf ${cwd}/tmp/bacula-restores
135 touch ${cwd}/build/po/test.po
137 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
138 @############################################################
139 @# Run a new Incremental, restore melting Copy and Backup
140 @# and copy the new job to Changer
144 @############################################################
145 @$out ${cwd}/tmp/log4.out
149 restore where=${cwd}/tmp/bacula-restores select all
154 update volume=FileVolume001 VolStatus=Used
155 update volume=FileVolume002 VolStatus=Used
156 run job=copy-volume yes
164 check_for_zombie_jobs storage=DiskChanger
169 get_mig_info 1 ${cwd}/tmp/log11.out
171 if [ -z "$RET" -o "$RET" = 0 ]; then
173 print_debug "The first job must have been copied"
176 get_mig_info 2 ${cwd}/tmp/log11.out
178 if [ -n "$RET" ]; then
180 print_debug "The second job has no files, it can't have been copied"
183 JOBID=`awk -F= '/Job queued. JobId/ {if(!f){print $2; f=1;}}' ${cwd}/tmp/log4.out`
184 get_mig_info $JOBID ${cwd}/tmp/log4.out
186 if [ -z "$RET" -o "$RET" = 0 ]; then
188 print_debug "The new incremental job must have been copied"