]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/base-job-test
Tweak correct English in debug output of regress tests
[bacula/bacula] / regress / tests / base-job-test
1 #!/bin/sh
2 #
3 # Run a basejob backup of the Bacula build directory
4 #   then restore it.
5 #
6
7 TestName="base-job-test"
8 JobName=backup
9 . scripts/functions
10 $rscripts/cleanup
11
12 copy_test_confs
13 echo 's/backup_advance/base_backup/' > $tmp/s
14 echo 's/Name = backup/Name = backup; Base = base_backup, backup/' >> $tmp/s
15 sed -f $tmp/s $rscripts/bacula-dir.conf.accurate > $conf/bacula-dir.conf
16 rm -f $tmp/s
17
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 }
29
30 # cleanup
31 rm -rf ${cwd}/build/accurate.new
32 rm -rf ${cwd}/build/accurate
33
34
35 # add extra files
36 mkdir ${cwd}/build/accurate
37 mkdir ${cwd}/build/accurate/dirtest
38 echo "test test" > ${cwd}/build/accurate/dirtest/hello
39 echo "test test" > ${cwd}/build/accurate/xxx
40 echo "test test" > ${cwd}/build/accurate/yyy
41 echo "test test" > ${cwd}/build/accurate/zzz
42 echo "test test" > ${cwd}/build/accurate/zzzzzz
43 echo "test test" > ${cwd}/build/accurate/xxxxxx
44 echo "test test" > ${cwd}/build/accurate/yyyyyy
45 echo "test test" > ${cwd}/build/accurate/xxxxxxxxx
46 echo "test test" > ${cwd}/build/accurate/yyyyyyyyy
47 echo "test test" > ${cwd}/build/accurate/zzzzzzzzz
48 echo ${cwd}/build > ${cwd}/tmp/file-list
49
50 start_test
51
52 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
53 @output /dev/null
54 messages
55 label volume=TestVolume001 storage=File pool=Default
56 messages
57 END_OF_DATA
58
59 run_bacula
60
61 ################################################################
62 p Now do a backup using base backup
63 ################################################################
64
65 echo ${cwd}/bin >> ${cwd}/tmp/file-list
66
67 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
68 @$out ${cwd}/tmp/log1.out
69 run job=base_backup level=base yes
70 wait
71 messages
72 update volume=TestVolume001 volstatus=Used
73 END_OF_DATA
74
75 run_bconsole
76
77 echo ${cwd}/build > ${cwd}/tmp/file-list
78
79 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
80 @$out ${cwd}/tmp/log4.out
81 label volume=TestVolume002 storage=File pool=Default
82 run job=backup level=full yes
83 wait
84 messages
85 @# 
86 @# now do a restore
87 @#
88 @$out ${cwd}/tmp/log2.out  
89 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
90 yes
91 wait
92 messages
93 END_OF_DATA
94
95
96 run_bconsole
97 check_for_zombie_jobs storage=File
98
99 check_two_logs
100 check_restore_diff
101
102 rm -rf ${cwd}/tmp/bacula-restores
103
104 grep -e 'FD Bytes Written: *0' ${cwd}/tmp/log4.out > /dev/null
105 if [ $? -ne 0 ]; then
106     print_debug "ERROR: The first full job should have 0 byte in log4.out"
107     bstat=2
108 fi
109
110 grep -e 'Using BaseJobId(s): 1$'  ${cwd}/tmp/log4.out > /dev/null
111 if [ $? -ne 0 ]; then
112     print_debug "ERROR: The first full job should use only jobid=1 as basejob"
113     bstat=2
114 fi
115
116 ################################################################
117 p Now do a backup after making few changes
118 ################################################################
119 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
120 @$out ${cwd}/tmp/log1.out
121 update volume=TestVolume002 volstatus=Used
122 label volume=TestVolume003 storage=File pool=Default
123 run job=backup level=incremental yes
124 wait
125 messages
126 list files jobid=4
127 @# 
128 @# now do a restore
129 @#
130 @$out ${cwd}/tmp/log2.out  
131 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
132 yes
133 wait
134 messages
135 END_OF_DATA
136
137 rm ${cwd}/build/accurate/yyyyyy  # delete a file
138 rm -rf ${cwd}/build/accurate/dirtest
139
140
141 run_bconsole
142 check_for_zombie_jobs storage=File
143
144 check_two_logs
145 check_restore_diff
146 check_files_written ${cwd}/tmp/log1.out 4
147
148 rm -rf ${cwd}/tmp/bacula-restores
149
150 ################################################################
151 p Test the job purge
152 ################################################################
153 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
154 @$out ${cwd}/tmp/log3.out
155 sql
156 SELECT count(*) FROM BaseFiles;
157
158 purge volume=TestVolume002
159 messages
160 sql
161 SELECT count(*) FROM BaseFiles;
162
163 END_OF_DATA
164
165 run_bconsole
166
167 grep -e ' 0 *|' ${cwd}/tmp/log3.out > /dev/null
168 if [ $? -ne 0 ]; then
169     print_debug "ERROR: Can't purge the base job"
170     estat=1
171 fi
172
173
174 ################################################################
175 p Test list commands
176 ################################################################
177
178 touch ${cwd}/build/po/fr.po
179
180 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
181 run level=full job=backup yes
182 wait
183 messages
184 @out ${cwd}/tmp/log5.out
185 list basefiles jobid=6
186 @out ${cwd}/tmp/log6.out
187 list files jobid=6
188 messages
189 END_OF_DATA
190
191 run_bconsole
192
193 grep "po/fr.po^" ${cwd}/tmp/log5.out > /dev/null
194 if [ $? -eq 0 ]; then
195     print_debug "ERROR: Should not display fr.po as basefile"
196     estat=2
197 fi
198
199 export bstat dstat estat
200
201 stop_bacula
202 end_test