]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/accurate-test
regress: test restore object in plugin-test
[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
11 TestName="accurate-test"
12 JobName=backup
13 . scripts/functions
14 $rscripts/cleanup
15
16 copy_test_confs
17 cp -f $rscripts/bacula-dir.conf.accurate $conf/bacula-dir.conf
18 sed s/all,/all,saved,/ $conf/bacula-fd.conf > tmp/1
19 cp tmp/1 $conf/bacula-fd.conf
20
21 change_jobname BackupClient1 $JobName
22
23 p() {
24    echo "##############################################" >> ${cwd}/tmp/log1.out
25    echo "$*" >> ${cwd}/tmp/log1.out
26    echo "##############################################" >> ${cwd}/tmp/log2.out
27    echo "$*" >> ${cwd}/tmp/log2.out
28    if test "$debug" -eq 1 ; then
29       echo "##############################################"
30       echo "$*"
31    fi
32 }
33
34 # cleanup
35 rm -rf ${cwd}/build/accurate.new
36 rm -rf ${cwd}/build/accurate
37
38
39 # add extra files
40 mkdir -p ${cwd}/build/accurate
41 mkdir -p ${cwd}/build/accurate/dirtest
42 echo "test test" > ${cwd}/build/accurate/dirtest/hello
43 echo "test test" > ${cwd}/build/accurate/xxx
44 echo "test test" > ${cwd}/build/accurate/yyy
45 echo "test test" > ${cwd}/build/accurate/zzz
46 echo "test test" > ${cwd}/build/accurate/zzzzzz
47 echo "test test" > ${cwd}/build/accurate/xxxxxx
48 echo "test test" > ${cwd}/build/accurate/yyyyyy
49 echo "test test" > ${cwd}/build/accurate/xxxxxxxxx
50 echo "test test" > ${cwd}/build/accurate/yyyyyyyyy
51 echo "test test" > ${cwd}/build/accurate/zzzzzzzzz
52 echo ${cwd}/build > ${cwd}/tmp/file-list
53
54 start_test
55
56 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
57 @$out /dev/null
58 messages
59 label volume=TestVolume001 storage=File pool=Default
60 messages
61 END_OF_DATA
62
63 run_bacula
64
65 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
66 @$out ${cwd}/tmp/log1.out
67 run job=$JobName yes
68 wait
69 messages
70 @# 
71 @# now do a restore
72 @#
73 @$out ${cwd}/tmp/log2.out  
74 setdebug level=10 storage=File
75 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
76 yes
77 wait
78 messages
79 quit
80 END_OF_DATA
81
82 ################################################################
83 p First :  We just run full and restore to compare if all is ok
84 ################################################################
85
86 run_bconsole
87 check_for_zombie_jobs storage=File
88
89 check_two_logs
90 check_restore_diff
91
92 rm -rf ${cwd}/tmp/bacula-restores
93
94 ################################################################
95 p Now do a second backup after making few changes
96 ################################################################
97 rm ${cwd}/build/accurate/xxx  # delete a file
98 rm ${cwd}/build/accurate/dirtest/hello
99
100 run_bconsole
101 check_for_zombie_jobs storage=File
102
103 check_two_logs
104 check_restore_diff
105 check_files_written ${cwd}/tmp/log1.out 4
106
107 rm -rf ${cwd}/tmp/bacula-restores
108
109 ################################################################
110 p Now do a third backup after making few changes
111 ################################################################
112 rm ${cwd}/build/accurate/yyyyyy  # delete a file
113 rmdir ${cwd}/build/accurate/dirtest
114
115 run_bconsole
116 check_for_zombie_jobs storage=File
117
118 check_two_logs
119 check_restore_diff
120 check_files_written ${cwd}/tmp/log1.out 3
121
122 rm -rf ${cwd}/tmp/bacula-restores
123
124 ################################################################
125 p Now do a 4 backup after making few changes
126 ################################################################
127 rm ${cwd}/build/accurate/zzzzzz  # delete a file
128
129 run_bconsole
130 check_for_zombie_jobs storage=File
131
132 check_two_logs
133 check_restore_diff
134 check_files_written ${cwd}/tmp/log1.out 2
135
136 rm -rf ${cwd}/tmp/bacula-restores
137
138 ################################################################
139 p Now do a 5 backup after making few changes
140 ################################################################
141 rm ${cwd}/build/accurate/zzzzzzzzz
142
143 run_bconsole
144 check_for_zombie_jobs storage=File
145
146 check_two_logs
147 check_restore_diff
148 check_files_written ${cwd}/tmp/log1.out 2
149
150 rm -rf ${cwd}/tmp/bacula-restores
151
152 ################################################################
153 p Now do a backup after making few changes
154 ################################################################
155 touch ${cwd}/build/accurate/aaaaaa
156
157 run_bconsole
158 check_for_zombie_jobs storage=File
159
160 check_two_logs
161 check_restore_diff
162 check_files_written ${cwd}/tmp/log1.out 2
163
164 rm -rf ${cwd}/tmp/bacula-restores
165
166 ################################################################
167 p Check with bls
168 ################################################################
169
170 $bin/bls -c $conf/bacula-sd.conf -V 'TestVolume001' FileStorage > $tmp/bls.out
171 grep -- '----' $tmp/bls.out | grep xxx > /dev/null
172 if [ $? != 0 ] ; then
173     print_debug "ERROR: Should find deleted files into $tmp/bls.out"
174     bstat=2
175 fi
176
177 ################################################################
178 p Now do a backup after making few changes
179 ################################################################
180
181 # some files will have disappear, others have their old mtime/ctime
182 mv ${cwd}/build/accurate ${cwd}/build/accurate.new
183
184 run_bconsole
185 check_for_zombie_jobs storage=File
186
187 check_two_logs
188 check_restore_diff
189
190 rm -rf ${cwd}/tmp/bacula-restores
191
192 ################################################################
193 p Now do an other test in differential mode
194 ################################################################
195
196 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
197 @$out ${cwd}/tmp/log1.out
198 run job=$JobName level=differential yes
199 wait
200 messages
201 @# 
202 @# now do a restore
203 @#
204 @$out ${cwd}/tmp/log2.out  
205 setdebug level=10 storage=File
206 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
207 yes
208 wait
209 messages
210 quit
211 END_OF_DATA
212
213 run_bconsole
214 check_for_zombie_jobs storage=File
215
216 check_two_logs
217 check_restore_diff
218
219 rm -rf ${cwd}/tmp/bacula-restores
220
221 ################################################################
222 p Now do an other test in differential mode + incremental
223 ################################################################
224
225 # make some changes
226 mv ${cwd}/build/accurate.new ${cwd}/build/accurate
227
228 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
229 @$out ${cwd}/tmp/log1.out
230 run job=$JobName yes
231 wait
232 messages
233 @# 
234 @# now do a restore
235 @#
236 @$out ${cwd}/tmp/log2.out  
237 setdebug level=10 storage=File
238 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
239 yes
240 wait
241 messages
242 quit
243 END_OF_DATA
244
245 run_bconsole
246 check_for_zombie_jobs storage=File
247
248 check_two_logs
249 check_restore_diff
250
251 rm -rf ${cwd}/tmp/bacula-restores
252
253 ################################################################
254 p Now do a backup after making few changes
255 ################################################################
256 rm ${cwd}/build/accurate/aaaaaa
257 touch ${cwd}/build/accurate/bbbbbb
258
259 run_bconsole
260 check_for_zombie_jobs storage=File
261 check_files_written ${cwd}/tmp/log1.out 3
262
263 check_two_logs
264 check_restore_diff
265
266 ################################################################
267 p Now do a backup after making few changes
268 ################################################################
269 mv ${cwd}/tmp/bacula-restores ${cwd}/build/accurate/
270
271 run_bconsole
272 check_for_zombie_jobs storage=File
273
274 check_two_logs
275 check_restore_diff
276
277 rm -rf ${cwd}/tmp/bacula-restores ${cwd}/build/accurate/bacula-restores
278
279 ################################################################
280 p Check with bscan
281 ################################################################
282
283 stop_bacula
284
285 cd $bin
286   ./drop_bacula_tables      >/dev/null 2>&1
287   ./make_bacula_tables      >/dev/null 2>&1
288   ./grant_bacula_privileges >/dev/null 2>&1
289 cd ..
290
291 echo "volume=TestVolume001" >tmp/bscan.bsr
292
293 bscan_libdbi
294
295 $bin/bscan -c $conf/bacula-sd.conf $BSCANLIBDBI -n "$db_name" -u "$db_user" -m -s -b $tmp/bscan.bsr FileStorage 2>&1 > $tmp/bscan.log
296
297 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
298 @$out ${cwd}/tmp/log1.out
299 messages
300 @# 
301 @# now do a restore after bscan
302 @#
303 @$out ${cwd}/tmp/log2.out  
304 setdebug level=10 storage=File
305 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
306 yes
307 wait
308 messages
309 quit
310 END_OF_DATA
311
312 # run bacula with just the restore job
313 run_bacula
314
315 check_for_zombie_jobs storage=File
316
317 check_two_logs
318 check_restore_diff
319
320 rm -rf ${cwd}/tmp/bacula-restores
321
322 ################################################################
323 p Now do a test with other attributes: owner, gid, rights
324 ################################################################
325
326 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
327 @$out ${cwd}/tmp/log1.out
328 label volume=TestVolume002 storage=File pool=Default
329 run job=backup_advance yes
330 wait
331 messages
332 @# 
333 @# now do a restore
334 @#
335 @$out ${cwd}/tmp/log2.out  
336 setdebug level=10 storage=File
337 restore fileset=FS_TESTJOB_ADVANCE where=${cwd}/tmp/bacula-restores select all done
338 yes
339 wait
340 messages
341 quit
342 END_OF_DATA
343
344 run_bconsole
345 check_for_zombie_jobs storage=File
346
347 check_two_logs
348 check_restore_diff
349
350 rm -rf ${cwd}/tmp/bacula-restores
351
352
353 ################################################################
354 p Use the p option for verify
355 ################################################################
356
357 chmod 400 ${cwd}/build/accurate/yyy
358
359 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
360 @$out ${cwd}/tmp/log1.out
361 run job=backup_advance yes
362 wait
363 messages
364 @# 
365 @# now do a restore
366 @#
367 @$out ${cwd}/tmp/log2.out  
368 setdebug level=10 storage=File
369 restore fileset=FS_TESTJOB_ADVANCE where=${cwd}/tmp/bacula-restores select all done
370 yes
371 wait
372 messages
373 quit
374 END_OF_DATA
375
376 run_bconsole
377 check_for_zombie_jobs storage=File
378
379 check_two_logs
380 check_restore_diff
381 check_files_written ${cwd}/tmp/log1.out 1
382
383 rm -rf ${cwd}/tmp/bacula-restores
384
385 ################################################################
386 p Test strippath option
387 ################################################################
388
389 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
390 @$out ${cwd}/tmp/log1.out
391 setdebug  level=1 client=$CLIENT
392 run job=backup fileset=FS_TESTJOB2 yes
393 wait
394 messages
395 @$out ${cwd}/tmp/log3.out
396 st dir
397 quit
398 END_OF_DATA
399
400 run_bconsole
401 check_for_zombie_jobs storage=File
402
403 # run incremental
404 rm -f ${cwd}/build/accurate/yyy
405 run_bconsole
406 check_for_zombie_jobs storage=File
407
408 jobid=`awk '/ Incr.+backup/ { jobid=$1 } END { print jobid }' ${cwd}/tmp/log3.out`
409
410 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
411 @$out ${cwd}/tmp/log3.out
412 list files jobid=$jobid
413 quit
414 END_OF_DATA
415
416 run_bconsole
417
418 grep yyy ${cwd}/tmp/log3.out > /dev/null
419 if [ $? != 0 ] ; then
420     print_debug "ERROR: Can't find yyy file into 'list files' output (${cwd}/tmp/log3.out)"
421     dstat=2
422 fi
423
424 grep zzz ${cwd}/tmp/log3.out > /dev/null
425 if [ $? = 0 ] ; then
426     print_debug "ERROR: Should not find zzz file into 'list files' output (${cwd}/tmp/log3.out)"
427     dstat=2
428 fi
429
430 stop_bacula
431 end_test