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