]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/verify-data-test
a040d71d9d7b4edb7881b1062100f2d58ecd2a03
[bacula/bacula] / regress / tests / verify-data-test
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2017 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6 #
7 # Run a simple backup of the Bacula build directory
8 #   then verify the data on the volume.           
9 #
10 TestName="verify-data-test"
11 JobName=VerifyVol
12 . scripts/functions
13
14 require_linux
15
16 cwd=`pwd`
17 scripts/cleanup
18 scripts/copy-test-confs
19 echo "${cwd}/tmp/files" >$tmp/file-list
20 echo "${cwd}/build/src/dird"      >>$tmp/file-list
21 echo "${cwd}/build/src/filed"     >>$tmp/file-list
22
23 #
24 # Add this back when verify can handle sparse files
25 #  the same way that backup does
26 #
27 mkdir -p $tmp/files
28 dd if=${cwd}/build/configure of=$tmp/files/sparsefile bs=1 count=1 seek=10M > /dev/null
29
30 change_jobname NightlySave $JobName
31 start_test
32
33 cat <<END_OF_DATA >tmp/bconcmds
34 @output /dev/null
35 messages
36 @$out tmp/log1.out
37 label storage=File volume=TestVolume001
38 run job=$JobName level=full fileset=FS1 yes
39 run job=$JobName level=full fileset=FS5 yes
40 run job=$JobName level=full fileset=FSno5 yes
41 run job=$JobName level=full fileset=FS5nocheck yes
42 wait
43 messages
44 @# 
45 @# now do a verify volume
46 @#
47 @$out ${cwd}/tmp/log2.out
48 setdebug level=10 client
49 run job=VerifyData jobid=1 yes
50 run job=VerifyData jobid=2 yes
51 run job=VerifyData jobid=3 yes
52 run job=VerifyData jobid=4 yes
53 wait
54 messages
55 quit
56 END_OF_DATA
57
58 run_bacula
59
60 sleep 2
61 check_for_zombie_jobs storage=File 
62 stop_bacula
63
64 $bperl -e 'add_attribute("$conf/bacula-sd.conf", "BlockChecksum", "no", "Device")'
65
66 #
67 # NOTE!!!  sed is an ASCII file editor not a binary file editor
68 #   Thus in general, the following sed will not work and is 
69 #   not portable.  It is known to fail on FreeBSD, but *seems* to work
70 #   on Linux.
71 #
72 # Introduce a volume error by modifying the some Volume data
73 nbok=2
74 if [ x$FORCE_DEDUP = xyes ]; then
75     nbok=4
76 elif [ x$FORCE_ALIGNED = xyes ]; then
77     sed -i 's/DUALCASE/PUALCASE/g' $tmp/TestVolume001.add
78 else
79     sed -i 's/DUALCASE/PUALCASE/g' $tmp/TestVolume001
80 fi
81
82 cat <<END_OF_DATA >tmp/bconcmds
83 @$out tmp/log3.out
84 @# 
85 @# now do a verify volume with errors.  Note, which JobId produces
86 @#  verify errors depends on the size of data stored (less with dedup
87 @#  and ALIGNED).  
88 @#
89 @$out ${cwd}/tmp/log3.out
90 setdebug level=10 client
91 run job=VerifyData jobid=1 yes
92 run job=VerifyData jobid=2 yes
93 run job=VerifyData jobid=3 yes
94 run job=VerifyData jobid=4 yes
95 wait
96 messages
97 quit
98 END_OF_DATA
99
100 run_bacula
101
102 sleep 2
103 check_for_zombie_jobs storage=File
104 stop_bacula
105
106 nb=`grep "^  Termination: *Backup OK" tmp/log1.out | wc -l`
107 if [ $nb -ne 4 ]; then
108     bstat=1
109 fi
110 nb=`grep "^  Termination: *Verify OK" tmp/log2.out | wc -l`
111 if [ $nb -ne 4 ]; then
112     vstat=1
113 fi
114 nb=`grep "^  Termination: *Verify OK" tmp/log3.out | wc -l`
115 if [ $nb -ne $nbok ]; then
116     echo "nb=${nb} nbok=${nbok}"
117     echo "tmp/log3.out"
118     cat tmp/log3.out
119     vstat=2
120 fi
121 dstat=0
122 end_test