3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
8 # Run a backup of the Bacula build directory on two Volumes
9 # then copy it to another device.
11 # This script uses the virtual disk autochanger and migration scripts
13 TestName="copy-volume-test"
19 scripts/copy-migration-confs
20 scripts/prepare-disk-changer
21 echo "${cwd}/build" >${cwd}/tmp/file-list
22 #cp ${cwd}/bin/bacula-sd.conf ${cwd}/tmp/1
23 #sed "s%# Maximum File Size% Maximum File Size%" ${cwd}/tmp/1 >${cwd}/bin/bacula-sd.conf
25 change_jobname NightlySave $JobName
26 sed 's/migrate/copy/g' ${cwd}/bin/bacula-dir.conf > ${cwd}/tmp/1
27 sed 's/Migrate/Copy/g' ${cwd}/tmp/1 > ${cwd}/bin/bacula-dir.conf
28 rm -f ${cwd}/build/po/test.po >/dev/null
33 # Note, we first backup into Pool Default,
34 # then Copy into Pool Full.
35 # Pool Default uses Storage=File
36 # Pool Full uses Storage=DiskChanger
38 # Write out bconsole commands
39 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
42 @$out ${cwd}/tmp/log1.out
43 setdebug level=50 storage=DiskChanger
44 label storage=File volume=FileVolume001 Pool=Default
45 label storage=File volume=FileVolume002 Pool=Scratch
46 update Volume=FileVolume001 MaxVolBytes=3000000 pool=Default
47 label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Scratch drive=0
48 label storage=DiskChanger volume=ChangerVolume002 slot=2 Pool=Scratch drive=0
54 update volume=FileVolume001 VolStatus=Used
55 update volume=FileVolume002 VolStatus=Used
59 @$out ${cwd}/tmp/log11.out
60 @############################################################
61 @# should copy one job, and the second is empty
62 @############################################################
63 @# setdebug level=11 dir
64 @echo "Run copy-volume Job"
65 @#setdebug level=100 dir
66 run job=copy-volume yes
74 status storage=DiskChanger
84 select * from JobMedia where JobId=1;
87 @$out ${cwd}/tmp/log2.out
88 @############################################################
91 @# Check that copy uses JobId 1,2
92 @# Use File instead of DiskChanger
94 @############################################################
95 @# Note, here we are restoring from the original backup,
96 @# so if you specify storage=DiskChanger the restore will fail
97 restore where=${cwd}/tmp/bacula-restores select
108 check_for_zombie_jobs storage=File
111 # cleanup previous restore
112 rm -rf ${cwd}/tmp/bacula-restores
114 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
115 @############################################################
116 @# Purge File backup, and restore again
118 @# Check that copy uses other JobId
121 @############################################################
122 @$out ${cwd}/tmp/log3.out
123 setdebug level=50 storage=DiskChanger
124 purge volume=FileVolume001 yes
125 purge volume=FileVolume002 yes
126 @# Note, here we are restoring from the original backup,
127 @# so if you specify storage=DiskChanger the restore will fail
128 restore where=${cwd}/tmp/bacula-restores select
140 check_for_zombie_jobs storage=DiskChanger
143 # cleanup previous restore
144 rm -rf ${cwd}/tmp/bacula-restores
145 touch ${cwd}/build/po/test.po
147 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
148 @############################################################
149 @# Run a new Incremental, restore melting Copy and Backup
150 @# and copy the new job to Changer
154 @############################################################
155 @$out ${cwd}/tmp/log4.out
159 setdebug level=50 storage=DiskChanger
160 restore where=${cwd}/tmp/bacula-restores select all
165 update volume=FileVolume001 VolStatus=Used
166 update volume=FileVolume002 VolStatus=Used
167 run job=copy-volume yes
175 check_for_zombie_jobs storage=DiskChanger
180 get_mig_info 1 ${cwd}/tmp/log11.out
182 if [ -z "$RET" -o "$RET" = 0 ]; then
184 print_debug "The first job must have been copied"
187 get_mig_info 2 ${cwd}/tmp/log11.out
189 if [ -n "$RET" ]; then
191 print_debug "The second job has no files, it can't have been copied"
194 JOBID=`awk -F= '/Job queued. JobId/ {if(!f){print $2; f=1;}}' ${cwd}/tmp/log4.out`
195 get_mig_info $JOBID ${cwd}/tmp/log4.out
197 if [ -z "$RET" -o "$RET" = 0 ]; then
199 print_debug "The new incremental job must have been copied"