]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/accurate-test
ebl Add strip path option
[bacula/bacula] / regress / tests / accurate-test
1 #!/bin/sh
2 #
3 # TODO:
4 #  - test bextract
5 #  - with strip path 
6 #
7 # Run a accurate backup of the Bacula build directory
8 #   then restore it.
9 #
10 TestName="accurate-test"
11 JobName=backup
12 . scripts/functions
13 scripts/cleanup
14
15 copy_test_confs
16 /bin/cp -f scripts/bacula-dir.conf.accurate bin/bacula-dir.conf
17 sed -i s/all,/all,saved,/ bin/bacula-fd.conf
18
19 change_jobname Client1 $JobName
20
21 # cleanup
22 rm -rf ${cwd}/build/accurate.new
23 rm -rf ${cwd}/build/accurate
24
25
26 # add extra files
27 mkdir ${cwd}/build/accurate
28 echo "test test" > ${cwd}/build/accurate/xxx
29 echo "test test" > ${cwd}/build/accurate/yyy
30 echo "test test" > ${cwd}/build/accurate/zzz
31 echo ${cwd}/build > ${cwd}/tmp/file-list
32
33 start_test
34
35 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
36 @output /dev/null
37 messages
38 label volume=TestVolume001 storage=File pool=Default
39 messages
40 END_OF_DATA
41
42 run_bacula
43
44 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
45 @$out ${cwd}/tmp/log1.out
46 run job=$JobName yes
47 wait
48 messages
49 @# 
50 @# now do a restore
51 @#
52 @$out ${cwd}/tmp/log2.out  
53 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
54 yes
55 wait
56 messages
57 @$out
58 quit
59 END_OF_DATA
60
61 ################################################################
62 # First :  We just run full and restore to compare if all is ok
63 ################################################################
64
65 run_bconsole
66 check_for_zombie_jobs storage=File
67
68 check_two_logs
69 check_restore_diff
70
71 rm -rf ${cwd}/tmp/bacula-restores
72
73 ################################################################
74 # Now do a second backup after making few changes
75 ################################################################
76 rm ${cwd}/build/accurate/xxx  # delete a file
77
78 run_bconsole
79 check_for_zombie_jobs storage=File
80
81 check_two_logs
82 check_restore_diff
83
84 rm -rf ${cwd}/tmp/bacula-restores
85
86 ################################################################
87 # Check with bls
88 ################################################################
89
90 ${cwd}/bin/bls -c ${cwd}/bin/bacula-sd.conf -V 'TestVolume001' FileStorage > tmp/bls.out
91 if ! grep -- '----' tmp/bls.out | grep xxx > /dev/null
92 then
93     bstat=2
94 fi
95
96 ################################################################
97 # Now do a third backup after making few changes
98 ################################################################
99
100 # some files will have disappear, others have their old mtime/ctime
101 mv ${cwd}/build/accurate ${cwd}/build/accurate.new
102
103 run_bconsole
104 check_for_zombie_jobs storage=File
105
106 check_two_logs
107 check_restore_diff
108
109 rm -rf ${cwd}/tmp/bacula-restores
110
111 ################################################################
112 # Now do an other test in differential mode
113 ################################################################
114
115 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
116 @$out ${cwd}/tmp/log1.out
117 run job=$JobName level=differential yes
118 wait
119 messages
120 @# 
121 @# now do a restore
122 @#
123 @$out ${cwd}/tmp/log2.out  
124 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
125 yes
126 wait
127 messages
128 @$out
129 quit
130 END_OF_DATA
131
132 run_bconsole
133 check_for_zombie_jobs storage=File
134
135 check_two_logs
136 check_restore_diff
137
138 rm -rf ${cwd}/tmp/bacula-restores
139
140 ################################################################
141 # Now do an other test in differential mode + incremental
142 ################################################################
143
144 # make some changes
145 mv ${cwd}/build/accurate.new ${cwd}/build/accurate
146
147 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
148 @$out ${cwd}/tmp/log1.out
149 run job=$JobName yes
150 wait
151 messages
152 @# 
153 @# now do a restore
154 @#
155 @$out ${cwd}/tmp/log2.out  
156 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
157 yes
158 wait
159 messages
160 @$out
161 quit
162 END_OF_DATA
163
164 run_bconsole
165 check_for_zombie_jobs storage=File
166
167 check_two_logs
168 check_restore_diff
169
170 rm -rf ${cwd}/tmp/bacula-restores
171
172 ################################################################
173 # Check with bscan
174 ################################################################
175
176 stop_bacula
177
178 cd ${cwd}/bin
179   ./drop_bacula_tables      >/dev/null 2>&1
180   ./make_bacula_tables      >/dev/null 2>&1
181   ./grant_bacula_privileges >/dev/null 2>&1
182 cd ..
183
184 echo "volume=TestVolume001" >tmp/bscan.bsr
185
186 ${cwd}/bin/bscan -c ${cwd}/bin/bacula-sd.conf -n regress -u regress -m -s -b tmp/bscan.bsr FileStorage 2>&1 > ${cwd}/tmp/bscan.log
187
188 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
189 @$out ${cwd}/tmp/log1.out
190 messages
191 @# 
192 @# now do a restore
193 @#
194 @$out ${cwd}/tmp/log2.out  
195 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
196 yes
197 wait
198 messages
199 @$out
200 quit
201 END_OF_DATA
202
203 # run bacula with just the restore job
204 run_bacula
205
206 check_for_zombie_jobs storage=File
207
208 check_two_logs
209 check_restore_diff
210
211 rm -rf ${cwd}/tmp/bacula-restores
212
213 ################################################################
214 # Now do a test with other attributes (owner, gid, rights)
215 ################################################################
216
217 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
218 @$out ${cwd}/tmp/log1.out
219 label volume=TestVolume002 storage=File pool=Default
220 run job=backup_advance yes
221 wait
222 messages
223 @# 
224 @# now do a restore
225 @#
226 @$out ${cwd}/tmp/log2.out  
227 restore fileset=FS_TESTJOB_ADVANCE where=${cwd}/tmp/bacula-restores select all done
228 yes
229 wait
230 messages
231 @$out
232 quit
233 END_OF_DATA
234
235 run_bconsole
236 check_for_zombie_jobs storage=File
237
238 check_two_logs
239 check_restore_diff
240
241 rm -rf ${cwd}/tmp/bacula-restores
242
243
244 ################################################################
245 # Use the p option for verify
246 ################################################################
247
248 chmod 400 ${cwd}/build/accurate/yyy
249
250 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
251 @$out ${cwd}/tmp/log1.out
252 run job=backup_advance yes
253 wait
254 messages
255 @# 
256 @# now do a restore
257 @#
258 @$out ${cwd}/tmp/log2.out  
259 restore fileset=FS_TESTJOB_ADVANCE where=${cwd}/tmp/bacula-restores select all done
260 yes
261 wait
262 messages
263 @$out
264 quit
265 END_OF_DATA
266
267 run_bconsole
268 check_for_zombie_jobs storage=File
269
270 check_two_logs
271 check_restore_diff
272
273 rm -rf ${cwd}/tmp/bacula-restores
274
275 if ! grep 'st_mode  differ' tmp/log1.out > /dev/null
276 then
277     bstat=2
278 fi
279
280 ################################################################
281 # Test strippath option
282 ################################################################
283
284 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
285 @$out ${cwd}/tmp/log1.out
286 setdebug  level=1 client
287 run job=backup fileset=FS_TESTJOB2 yes
288 wait
289 messages
290 @$out ${cwd}/tmp/log3.out
291 st dir
292 quit
293 END_OF_DATA
294
295 run_bconsole
296 check_for_zombie_jobs storage=File
297
298 # run incremental
299 rm -f ${cwd}/build/accurate/yyy
300 run_bconsole
301 check_for_zombie_jobs storage=File
302
303 jobid=$(awk '/ Incr.+backup/ { jobid=$1 } END { print jobid }' ${cwd}/tmp/log3.out)
304
305 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
306 @$out ${cwd}/tmp/log3.out
307 list files jobid=$jobid
308 quit
309 END_OF_DATA
310
311 run_bconsole
312
313 if ! grep yyy ${cwd}/tmp/log3.out > /dev/null
314 then
315     bstat=2
316 fi
317
318 if grep zzz ${cwd}/tmp/log3.out > /dev/null
319 then
320     bstat=2
321 fi
322
323 stop_bacula
324 end_test
325