]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/base-job-test
Reduce debug output
[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 "The first full job should have 0 byte in log4.out"
107     bstat=2
108 fi
109
110 ################################################################
111 p Now do a backup after making few changes
112 ################################################################
113 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
114 @$out ${cwd}/tmp/log1.out
115 update volume=TestVolume002 volstatus=Used
116 label volume=TestVolume003 storage=File pool=Default
117 run job=backup level=incremental yes
118 wait
119 messages
120 @# 
121 @# now do a restore
122 @#
123 @$out ${cwd}/tmp/log2.out  
124 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
125 yes
126 wait
127 messages
128 END_OF_DATA
129
130 rm ${cwd}/build/accurate/yyyyyy  # delete a file
131 rm -rf ${cwd}/build/accurate/dirtest
132
133
134 run_bconsole
135 check_for_zombie_jobs storage=File
136
137 check_two_logs
138 check_restore_diff
139 check_files_written ${cwd}/tmp/log1.out 4
140
141 rm -rf ${cwd}/tmp/bacula-restores
142
143 ################################################################
144 p Test the job purge
145 ################################################################
146 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
147 @$out ${cwd}/tmp/log3.out
148 sql
149 SELECT count(*) FROM BaseFiles;
150
151 purge volume=TestVolume002
152 messages
153 sql
154 SELECT count(*) FROM BaseFiles;
155
156 END_OF_DATA
157
158 run_bconsole
159
160 grep -e ' 0 *|' ${cwd}/tmp/log3.out > /dev/null
161 if [ $? -ne 0 ]; then
162     print_debug "Can't purge the base job"
163     estat=1
164 fi
165
166
167 ################################################################
168 p Test list commands
169 ################################################################
170
171 touch ${cwd}/build/po/fr.po
172
173 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
174 run level=full job=backup yes
175 wait
176 messages
177 @out ${cwd}/tmp/log5.out
178 list basefiles jobid=6
179 @out ${cwd}/tmp/log6.out
180 list files jobid=6
181 messages
182 END_OF_DATA
183
184 run_bconsole
185
186 grep "po/fr.po^" ${cwd}/tmp/log5.out > /dev/null
187 if [ $? -eq 0 ]; then
188     print_debug "Should not display fr.po as basefile"
189     estat=2
190 fi
191
192 export bstat dstat estat
193
194 stop_bacula
195 end_test