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