]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/virtual-jobid-test
Make out of freespace non-fatal for removable devices -- i.e. behaves like tape
[bacula/bacula] / regress / tests / virtual-jobid-test
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2017 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6 # Run a simple backup of the Bacula build directory then do a 
7 #   Virtual Full backup to another device.
8 #
9 # This script uses the disk autochanger
10 #
11 TestName="virtual-jobid-test"
12 JobName=Vbackup
13 . scripts/functions
14
15
16 scripts/cleanup
17 scripts/copy-migration-confs
18 echo "${cwd}/build" >${cwd}/tmp/file-list
19
20 rm -f $cwd/build/inc1 $cwd/build/inc2 $cwd/build/diff1
21
22 change_jobname NightlySave $JobName
23 start_test
24
25 #
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
30
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 # +-------+---------+-------+----------+----------+-----------+
40
41 # Write out bconsole commands
42 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
43 @output /dev/null
44 messages
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
50 @# run several jobs
51 @exec "sh -c 'date > ${cwd}/build/date'"
52 run job=$JobName level=Full yes
53 wait
54 messages
55 list jobs
56 @exec "sh -c 'touch ${cwd}/build/inc1'"
57 run job=$JobName level=Incremental yes
58 wait
59 messages
60 list jobs
61 @exec "sh -c 'touch ${cwd}/build/diff1'"
62 run job=$JobName level=Differential yes
63 wait
64 messages
65 list jobs
66 @exec "sh -c 'touch ${cwd}/build/inc2'"
67 run job=$JobName level=Incremental yes
68 wait
69 messages
70 list jobs
71 run job=Save level=Full yes
72 wait
73 messages
74 list jobs
75 @# should Consolidate Full, Incremental
76 @$out $tmp/log5.out
77 setdebug level=100 dir trace=1
78 run job=$JobName jobid=4 level=VirtualFull yes
79 wait
80 messages
81 list jobs
82 @$out $tmp/log6.out
83 run job=$JobName jobid=3 level=VirtualFull yes
84 wait
85 messages
86 list jobs
87 @$out $tmp/log7.out
88 run job=$JobName jobid=2 level=VirtualFull yes
89 wait
90 messages
91 list jobs
92 @$out $tmp/log8.out
93 run job=$JobName jobid=1,2 level=VirtualFull yes
94 wait
95 messages
96 list jobs
97 @$out $tmp/log9.out
98 run job=$JobName jobid=1,3 level=VirtualFull yes
99 wait
100 messages
101 list jobs
102 @$out $tmp/log10.out
103 run job=$JobName jobid=1,3,4 level=VirtualFull yes
104 wait
105 messages
106 list jobs
107 @$out $tmp/log11.out
108 run job=$JobName jobid=1-5 level=VirtualFull yes
109 wait
110 messages
111 list jobs
112 @$out $tmp/log12.out
113 run job=$JobName jobid=2-5 level=VirtualFull yes
114 wait
115 messages
116 list jobs
117 @$out $tmp/log13.out
118 run job=$JobName jobid=2,4 level=VirtualFull yes
119 wait
120 messages
121 list jobs
122 @$out $tmp/log14.out
123 run job=$JobName alljobid=1-5 level=VirtualFull yes
124 wait
125 messages
126 list jobs
127 @# 
128 @# now do a restore of the consolidated Full
129 @#
130 @$out $tmp/log2.out
131 restore jobid=8 where=${cwd}/tmp/restore1
132 m *
133 done
134 yes
135 wait
136 messages
137 restore jobid=7 where=${cwd}/tmp/restore2
138 m *
139 done
140 yes
141 wait
142 messages
143 restore jobid=6 where=${cwd}/tmp/bacula-restores
144 m *
145 done
146 yes
147 wait
148 messages
149 quit
150 END_OF_DATA
151
152 run_bacula
153 check_for_zombie_jobs storage=File
154 stop_bacula
155
156 #
157 # We only used one log so copy it to the second log
158 #  so that any restore errors will be picked up
159 #
160 check_two_logs
161 check_restore_diff
162
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"
166     estat=1
167 fi
168
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"
172     estat=1
173 fi
174
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"
178     estat=1
179 fi
180
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"
184     estat=1
185 fi
186
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"
190     estat=1
191 fi
192
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"
196     estat=1
197 fi
198
199
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"
202     estat=1
203 fi
204
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"
207     estat=2
208 fi
209
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"
212     estat=2
213 fi
214
215 end_test