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