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
115 run_bconsole ${cwd}/tmp/bconcmds.resto
119 cat <<EOF >${cwd}/tmp/bconcmds
120 @$out ${cwd}/tmp/log2.out
122 @# should restore with 1,2,3
124 @# should restore with 5,2,3
128 rm -rf ${cwd}/tmp/bacula-restores
129 run_bconsole ${cwd}/tmp/bconcmds.resto
133 # remove first copy of job=1
134 cat <<EOF >${cwd}/tmp/bconcmds
135 @$out ${cwd}/tmp/log2.out
137 @# should restore with 11,2,3
141 rm -rf ${cwd}/tmp/bacula-restores
142 run_bconsole ${cwd}/tmp/bconcmds.resto
146 # remove 2 copies at the same time
147 cat <<EOF >${cwd}/tmp/bconcmds
148 @$out ${cwd}/tmp/log2.out
150 @# should restore with 19,2,3
154 rm -rf ${cwd}/tmp/bacula-restores
155 run_bconsole ${cwd}/tmp/bconcmds.resto
159 # remove job and copies of jobid=3
160 cat <<EOF >${cwd}/tmp/bconcmds
161 @$out ${cwd}/tmp/log2.out
163 @# should restore with 19,2
167 rm -f ${cwd}/build/po/test1
168 rm -rf ${cwd}/tmp/bacula-restores
169 run_bconsole ${cwd}/tmp/bconcmds.resto
173 awk '/You have selected the following JobIds:/ { print $7 }' \
174 ${cwd}/tmp/log2.out > ${cwd}/tmp/real
175 awk '/should restore with/ { print $5 }' \
176 ${cwd}/tmp/log2.out > ${cwd}/tmp/should
178 diff -u ${cwd}/tmp/real ${cwd}/tmp/should
179 if [ $? -ne 0 ]; then
180 print_debug "Bad job selection!!!"
184 check_for_zombie_jobs storage=File