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 setdebug level=50 storage=DiskChanger
39 label storage=File volume=FileVolume001 Pool=Default
40 label storage=File volume=FileVolume002 Pool=Scratch
41 update Volume=FileVolume001 MaxVolBytes=3000000 pool=Default
42 label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Scratch drive=0
43 label storage=DiskChanger volume=ChangerVolume002 slot=2 Pool=Scratch drive=0
49 update volume=FileVolume001 VolStatus=Used
50 update volume=FileVolume002 VolStatus=Used
54 @$out ${cwd}/tmp/log11.out
55 @############################################################
56 @# should copy one job, and the second is empty
57 @############################################################
58 @# setdebug level=11 dir
59 @echo "Run copy-volume Job"
60 @#setdebug level=100 dir
61 run job=copy-volume yes
69 status storage=DiskChanger
79 select * from JobMedia where JobId=1;
82 @$out ${cwd}/tmp/log2.out
83 @############################################################
86 @# Check that copy uses JobId 1,2
87 @# Use File instead of DiskChanger
89 @############################################################
90 @# Note, here we are restoring from the original backup,
91 @# so if you specify storage=DiskChanger the restore will fail
92 restore where=${cwd}/tmp/bacula-restores select
103 check_for_zombie_jobs storage=File
106 # cleanup previous restore
107 rm -rf ${cwd}/tmp/bacula-restores
109 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
110 @############################################################
111 @# Purge File backup, and restore again
113 @# Check that copy uses other JobId
116 @############################################################
117 @$out ${cwd}/tmp/log3.out
118 setdebug level=50 storage=DiskChanger
119 purge volume=FileVolume001 yes
120 purge volume=FileVolume002 yes
121 @# Note, here we are restoring from the original backup,
122 @# so if you specify storage=DiskChanger the restore will fail
123 restore where=${cwd}/tmp/bacula-restores select
135 check_for_zombie_jobs storage=DiskChanger
138 # cleanup previous restore
139 rm -rf ${cwd}/tmp/bacula-restores
140 touch ${cwd}/build/po/test.po
142 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
143 @############################################################
144 @# Run a new Incremental, restore melting Copy and Backup
145 @# and copy the new job to Changer
149 @############################################################
150 @$out ${cwd}/tmp/log4.out
154 setdebug level=50 storage=DiskChanger
155 restore where=${cwd}/tmp/bacula-restores select all
160 update volume=FileVolume001 VolStatus=Used
161 update volume=FileVolume002 VolStatus=Used
162 run job=copy-volume yes
170 check_for_zombie_jobs storage=DiskChanger
175 get_mig_info 1 ${cwd}/tmp/log11.out
177 if [ -z "$RET" -o "$RET" = 0 ]; then
179 print_debug "The first job must have been copied"
182 get_mig_info 2 ${cwd}/tmp/log11.out
184 if [ -n "$RET" ]; then
186 print_debug "The second job has no files, it can't have been copied"
189 JOBID=`awk -F= '/Job queued. JobId/ {if(!f){print $2; f=1;}}' ${cwd}/tmp/log4.out`
190 get_mig_info $JOBID ${cwd}/tmp/log4.out
192 if [ -z "$RET" -o "$RET" = 0 ]; then
194 print_debug "The new incremental job must have been copied"