3 # Copyright (C) 2000-2017 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 @#setdebug level=100 Dir
45 label storage=File volume=FileVolume001 Pool=Default
46 label storage=File volume=FileVolume002 Pool=Scratch
47 update Volume=FileVolume001 MaxVolBytes=3000000 pool=Default
48 label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Scratch drive=0
49 label storage=DiskChanger volume=ChangerVolume002 slot=2 Pool=Scratch drive=0
55 update volume=FileVolume001 VolStatus=Used
56 update volume=FileVolume002 VolStatus=Used
60 @$out ${cwd}/tmp/log11.out
61 @############################################################
62 @# should copy one job, and the second is empty
63 @############################################################
64 @# setdebug level=11 dir
65 @echo "Run copy-volume Job"
66 @#setdebug level=100 dir
67 run job=copy-volume yes
75 status storage=DiskChanger
85 select * from JobMedia where JobId=1;
88 @$out ${cwd}/tmp/log2.out
89 @############################################################
92 @# Check that copy uses JobId 1,2
93 @# Use File instead of DiskChanger
95 @############################################################
96 @# Note, here we are restoring from the original backup,
97 @# so if you specify storage=DiskChanger the restore will fail
98 restore where=${cwd}/tmp/bacula-restores select
109 check_for_zombie_jobs storage=File
112 # cleanup previous restore
113 rm -rf ${cwd}/tmp/bacula-restores
115 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
116 @############################################################
117 @# Purge File backup, and restore again
119 @# Check that copy uses other JobId
122 @############################################################
123 @$out ${cwd}/tmp/log3.out
124 setdebug level=50 storage=DiskChanger
125 purge volume=FileVolume001 yes
126 purge volume=FileVolume002 yes
127 @# Note, here we are restoring from the original backup,
128 @# so if you specify storage=DiskChanger the restore will fail
129 restore where=${cwd}/tmp/bacula-restores select
141 check_for_zombie_jobs storage=DiskChanger
144 # cleanup previous restore
145 rm -rf ${cwd}/tmp/bacula-restores
146 touch ${cwd}/build/po/test.po
148 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
149 @############################################################
150 @# Run a new Incremental, restore melting Copy and Backup
151 @# and copy the new job to Changer
155 @############################################################
156 @$out ${cwd}/tmp/log4.out
160 setdebug level=50 storage=DiskChanger
161 restore where=${cwd}/tmp/bacula-restores select all
166 update volume=FileVolume001 VolStatus=Used
167 update volume=FileVolume002 VolStatus=Used
168 run job=copy-volume yes
176 check_for_zombie_jobs storage=DiskChanger
181 get_mig_info 1 ${cwd}/tmp/log11.out
183 if [ -z "$RET" -o "$RET" = 0 ]; then
185 print_debug "The first job must have been copied"
188 get_mig_info 2 ${cwd}/tmp/log11.out
190 if [ -n "$RET" ]; then
192 print_debug "The second job has no files, it can't have been copied"
195 JOBID=`awk -F= '/Job queued. JobId/ {if(!f){print $2; f=1;}}' ${cwd}/tmp/log4.out`
196 get_mig_info $JOBID ${cwd}/tmp/log4.out
198 if [ -z "$RET" -o "$RET" = 0 ]; then
200 print_debug "The new incremental job must have been copied"