3 # Run a simple backup of the Bacula build directory then copy it
4 # to another device. We test that when the original job is purged
5 # the next copy is "upgraded" to Type=B
7 # This script uses the virtual disk autochanger
9 TestName="copy-upgrade-test"
15 scripts/copy-migration-confs
16 scripts/prepare-disk-changer
17 echo "${cwd}/build" >${cwd}/tmp/file-list
18 sed 's/migrate/copy/g' ${cwd}/bin/bacula-dir.conf > ${cwd}/tmp/1
19 sed 's/Migrate/Copy/g' ${cwd}/tmp/1 > ${cwd}/bin/bacula-dir.conf
22 change_jobname NightlySave $JobName
26 # Note, we first backup into Pool Default,
27 # then Copy into Pool Full.
28 # Pool Default uses Storage=File
29 # Pool Full uses Storage=DiskChanger
31 # Write out bconsole commands
32 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
35 @$out ${cwd}/tmp/log1.out
36 @# setdebug level=100 storage=File
37 label storage=File volume=FileVolume001 Pool=Default
38 label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Full drive=0
39 label storage=DiskChanger volume=ChangerVolume002 slot=2 Pool=Full drive=0
47 echo test > ${cwd}/build/po/test
49 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
50 @$out ${cwd}/tmp/log1.out
51 run job=$JobName level=incremental yes
58 echo test1 > ${cwd}/build/po/test1
60 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
61 @$out ${cwd}/tmp/log1.out
62 run job=$JobName level=incremental yes
65 @# we should be able to purge jobid 1 3 times
66 update volume=FileVolume001 VolStatus=Used
68 run job=copy-job jobid=1 yes
71 run job=copy-job jobid=2 yes
74 run job=copy-job jobid=3 yes
77 run job=copy-job jobid=1 yes
80 run job=copy-job jobid=2 yes
83 run job=copy-job jobid=3 yes
86 run job=copy-job jobid=1 yes
89 run job=copy-job jobid=1 yes
98 cat<<END_OF_DATA > ${cwd}/tmp/bconcmds.resto
102 @$out ${cwd}/tmp/log2.out
104 restore copies where=${cwd}/tmp/bacula-restores select storage=DiskChanger
116 run_bconsole ${cwd}/tmp/bconcmds.resto
120 cat <<EOF >${cwd}/tmp/bconcmds
121 @$out ${cwd}/tmp/log2.out
123 @# should restore with 1,2,3
125 @# should restore with 5,2,3
129 rm -rf ${cwd}/tmp/bacula-restores
130 run_bconsole ${cwd}/tmp/bconcmds.resto
134 # remove first copy of job=1
135 cat <<EOF >${cwd}/tmp/bconcmds
136 @$out ${cwd}/tmp/log2.out
138 @# should restore with 11,2,3
142 rm -rf ${cwd}/tmp/bacula-restores
143 run_bconsole ${cwd}/tmp/bconcmds.resto
147 # remove 2 copies at the same time
148 cat <<EOF >${cwd}/tmp/bconcmds
149 @$out ${cwd}/tmp/log2.out
151 @# should restore with 19,2,3
155 rm -rf ${cwd}/tmp/bacula-restores
156 run_bconsole ${cwd}/tmp/bconcmds.resto
160 # remove job and copies of jobid=3
161 cat <<EOF >${cwd}/tmp/bconcmds
162 @$out ${cwd}/tmp/log2.out
164 @# should restore with 19,2
168 rm -f ${cwd}/build/po/test1
169 rm -rf ${cwd}/tmp/bacula-restores
170 run_bconsole ${cwd}/tmp/bconcmds.resto
174 awk '/You have selected the following JobIds:/ { print $7 }' \
175 ${cwd}/tmp/log2.out > ${cwd}/tmp/real
176 awk '/should restore with/ { print $5 }' \
177 ${cwd}/tmp/log2.out > ${cwd}/tmp/should
179 diff ${cwd}/tmp/real ${cwd}/tmp/should
180 if [ $? -ne 0 ]; then
181 print_debug "Bad job selection!!!"
185 check_for_zombie_jobs storage=File