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