]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/base-job-test
regress: Add test for new PurgeMigrateJob option
[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 @# 
127 @# now do a restore
128 @#
129 @$out ${cwd}/tmp/log2.out  
130 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
131 yes
132 wait
133 messages
134 END_OF_DATA
135
136 rm ${cwd}/build/accurate/yyyyyy  # delete a file
137 rm -rf ${cwd}/build/accurate/dirtest
138
139
140 run_bconsole
141 check_for_zombie_jobs storage=File
142
143 check_two_logs
144 check_restore_diff
145 check_files_written ${cwd}/tmp/log1.out 4
146
147 rm -rf ${cwd}/tmp/bacula-restores
148
149 ################################################################
150 p Test the job purge
151 ################################################################
152 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
153 @$out ${cwd}/tmp/log3.out
154 sql
155 SELECT count(*) FROM BaseFiles;
156
157 purge volume=TestVolume002
158 messages
159 sql
160 SELECT count(*) FROM BaseFiles;
161
162 END_OF_DATA
163
164 run_bconsole
165
166 grep -e ' 0 *|' ${cwd}/tmp/log3.out > /dev/null
167 if [ $? -ne 0 ]; then
168     print_debug "Can't purge the base job"
169     estat=1
170 fi
171
172
173 ################################################################
174 p Test list commands
175 ################################################################
176
177 touch ${cwd}/build/po/fr.po
178
179 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
180 run level=full job=backup yes
181 wait
182 messages
183 @out ${cwd}/tmp/log5.out
184 list basefiles jobid=6
185 @out ${cwd}/tmp/log6.out
186 list files jobid=6
187 messages
188 END_OF_DATA
189
190 run_bconsole
191
192 grep "po/fr.po^" ${cwd}/tmp/log5.out > /dev/null
193 if [ $? -eq 0 ]; then
194     print_debug "Should not display fr.po as basefile"
195     estat=2
196 fi
197
198 export bstat dstat estat
199
200 stop_bacula
201 end_test