3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
8 # Run a simple backup of the Bacula build directory then copy it
9 # to another device. We test that when the original job is purged
10 # the next copy is "upgraded" to Type=B
12 # This script uses the virtual disk autochanger
14 TestName="copy-upgrade-test"
20 scripts/copy-migration-confs
21 scripts/prepare-disk-changer
22 echo "${cwd}/build" >${cwd}/tmp/file-list
23 sed 's/migrate/copy/g' ${cwd}/bin/bacula-dir.conf > ${cwd}/tmp/1
24 sed 's/Migrate/Copy/g' ${cwd}/tmp/1 > ${cwd}/bin/bacula-dir.conf
27 change_jobname NightlySave $JobName
31 # Note, we first backup into Pool Default,
32 # then Copy into Pool Full.
33 # Pool Default uses Storage=File
34 # Pool Full uses Storage=DiskChanger
36 # Write out bconsole commands
37 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
40 @$out ${cwd}/tmp/log1.out
41 @# setdebug level=100 storage=File
42 label storage=File volume=FileVolume001 Pool=Default
43 label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Full drive=0
44 label storage=DiskChanger volume=ChangerVolume002 slot=2 Pool=Full drive=0
52 echo test > ${cwd}/build/po/test
54 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
55 @$out ${cwd}/tmp/log1.out
56 run job=$JobName level=incremental yes
63 echo test1 > ${cwd}/build/po/test1
65 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
66 @$out ${cwd}/tmp/log1.out
67 run job=$JobName level=incremental yes
70 @# we should be able to purge jobid 1 3 times
71 update volume=FileVolume001 VolStatus=Used
73 run job=copy-job jobid=1 yes
76 run job=copy-job jobid=2 yes
79 run job=copy-job jobid=3 yes
82 run job=copy-job jobid=1 yes
85 run job=copy-job jobid=2 yes
88 run job=copy-job jobid=3 yes
91 run job=copy-job jobid=1 yes
94 run job=copy-job jobid=1 yes
103 cat<<END_OF_DATA > ${cwd}/tmp/bconcmds.resto
107 @$out ${cwd}/tmp/log2.out
109 @# Note, here we are restoring from the original backup,
110 @# so if you specify storage=DiskChanger the restore will fail
111 restore copies where=${cwd}/tmp/bacula-restores select
122 run_bconsole ${cwd}/tmp/bconcmds.resto
126 cat <<EOF >${cwd}/tmp/bconcmds
127 @$out ${cwd}/tmp/log2.out
129 @# should restore with 1,2,3
131 @# should restore with 5,2,3
135 rm -rf ${cwd}/tmp/bacula-restores
136 run_bconsole ${cwd}/tmp/bconcmds.resto
140 # remove first copy of job=1
141 cat <<EOF >${cwd}/tmp/bconcmds
142 @$out ${cwd}/tmp/log2.out
144 @# should restore with 11,2,3
148 rm -rf ${cwd}/tmp/bacula-restores
149 run_bconsole ${cwd}/tmp/bconcmds.resto
153 # remove 2 copies at the same time
154 cat <<EOF >${cwd}/tmp/bconcmds
155 @$out ${cwd}/tmp/log2.out
157 @# should restore with 19,2,3
161 rm -rf ${cwd}/tmp/bacula-restores
162 run_bconsole ${cwd}/tmp/bconcmds.resto
166 # remove job and copies of jobid=3
167 cat <<EOF >${cwd}/tmp/bconcmds
168 @$out ${cwd}/tmp/log2.out
170 @# should restore with 19,2
174 rm -f ${cwd}/build/po/test1
175 rm -rf ${cwd}/tmp/bacula-restores
176 run_bconsole ${cwd}/tmp/bconcmds.resto
180 awk '/You have selected the following JobIds:/ { print $7 }' \
181 ${cwd}/tmp/log2.out > ${cwd}/tmp/real
182 awk '/should restore with/ { print $5 }' \
183 ${cwd}/tmp/log2.out > ${cwd}/tmp/should
185 diff -u ${cwd}/tmp/real ${cwd}/tmp/should
186 if [ $? -ne 0 ]; then
187 print_debug "Bad job selection!!!"
191 check_for_zombie_jobs storage=File