3 # Copyright (C) 2000-2017 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
6 # Run a simple backup of the Bacula build directory then do a
7 # Virtual Full backup to another device.
9 # This script uses the disk autochanger
11 TestName="virtual-jobid-test"
17 scripts/copy-migration-confs
18 echo "${cwd}/build" >${cwd}/tmp/file-list
20 rm -f $cwd/build/inc1 $cwd/build/inc2 $cwd/build/diff1
22 change_jobname NightlySave $JobName
26 # Note, we first backup into Pool Default,
27 # then Migrate into Pool Full.
28 # Pool Default uses Storage=File
29 # Pool Full uses Storage=DiskChanger
31 # +-------+---------+-------+----------+----------+-----------+
32 # | JobId | Name | Level | JobFiles | JobBytes | JobStatus |
33 # +-------+---------+-------+----------+----------+-----------+
34 # | 1 | Vbackup | F | 1754 | 50118554 | T |
35 # | 2 | Vbackup | I | 1 | 0 | T |
36 # | 3 | Vbackup | D | 2 | 0 | T |
37 # | 4 | Vbackup | I | 1 | 0 | T |
38 # | 5 | Save | F | 1754 | 50118554 | T |
39 # +-------+---------+-------+----------+----------+-----------+
41 # Write out bconsole commands
42 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
45 @$out ${cwd}/tmp/log1.out
46 @#setdebug level=100 storage=File
47 label storage=File volume=FileVolume001 Pool=Default
48 label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Full drive=0
49 label storage=DiskChanger volume=ChangerVolume002 slot=2 Pool=Full drive=0
51 @exec "sh -c 'date > ${cwd}/build/date'"
52 run job=$JobName level=Full yes
56 @exec "sh -c 'touch ${cwd}/build/inc1'"
57 run job=$JobName level=Incremental yes
61 @exec "sh -c 'touch ${cwd}/build/diff1'"
62 run job=$JobName level=Differential yes
66 @exec "sh -c 'touch ${cwd}/build/inc2'"
67 run job=$JobName level=Incremental yes
71 run job=Save level=Full yes
75 @# should Consolidate Full, Incremental
77 setdebug level=100 dir trace=1
78 run job=$JobName jobid=4 level=VirtualFull yes
83 run job=$JobName jobid=3 level=VirtualFull yes
88 run job=$JobName jobid=2 level=VirtualFull yes
93 run job=$JobName jobid=1,2 level=VirtualFull yes
98 run job=$JobName jobid=1,3 level=VirtualFull yes
103 run job=$JobName jobid=1,3,4 level=VirtualFull yes
108 run job=$JobName jobid=1-5 level=VirtualFull yes
113 run job=$JobName jobid=2-5 level=VirtualFull yes
118 run job=$JobName jobid=2,4 level=VirtualFull yes
123 run job=$JobName alljobid=1-5 level=VirtualFull yes
128 @# now do a restore of the consolidated Full
131 restore jobid=8 where=${cwd}/tmp/restore1
137 restore jobid=7 where=${cwd}/tmp/restore2
143 restore jobid=6 where=${cwd}/tmp/bacula-restores
153 check_for_zombie_jobs storage=File
157 # We only used one log so copy it to the second log
158 # so that any restore errors will be picked up
163 grep 'JobIds=1,2,3,4$' $tmp/log11.out > /dev/null
164 if [ $? -ne 0 ]; then
165 print_debug "ERROR: jobid list is not right in $tmp/log11.out"
169 grep 'JobIds=2,3,4$' $tmp/log12.out > /dev/null
170 if [ $? -ne 0 ]; then
171 print_debug "ERROR: jobid list is not right in $tmp/log12.out"
175 grep 'using Differential level' $tmp/log12.out > /dev/null
176 if [ $? -ne 0 ]; then
177 print_debug "ERROR: Final level should be differential in $tmp/log12.out"
181 grep 'JobIds=2,4$' $tmp/log13.out > /dev/null
182 if [ $? -ne 0 ]; then
183 print_debug "ERROR: jobid list is not right in $tmp/log13.out"
187 grep 'using Incremental level' $tmp/log13.out > /dev/null
188 if [ $? -ne 0 ]; then
189 print_debug "ERROR: Final level should be incremental in $tmp/log13.out"
193 grep 'JobIds=1,2,3,4,5$' $tmp/log14.out > /dev/null
194 if [ $? -ne 0 ]; then
195 print_debug "ERROR: jobid list is not right in $tmp/log14.out"
200 if [ ! -f $tmp/restore1/$cwd/build/inc1 -o -f $tmp/restore1/$cwd/build/diff1 -o -f $tmp/restore1/$cwd/build/inc2 ]; then
201 print_debug "ERROR: should find only inc1 in restore1"
205 if [ ! -f $tmp/restore2/$cwd/build/inc1 -o ! -f $tmp/restore2/$cwd/build/diff1 -o -f $tmp/restore2/$cwd/build/inc2 ]; then
206 print_debug "ERROR: should find only inc1 and diff1 in restore2"
210 if [ ! -f $tmp/bacula-restores/$cwd/build/inc1 -o ! -f $tmp/bacula-restores/$cwd/build/diff1 -o ! -f $tmp/bacula-restores/$cwd/build/inc2 ]; then
211 print_debug "ERROR: should find inc1, diff1 and inc2 in bacula-restores"