]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/base-job-test
tweak regress test
[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 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
59 @$out ${cwd}/tmp/log1.out
60 run job=backup level=full yes
61 wait
62 messages
63 @# 
64 @# now do a restore
65 @#
66 @$out ${cwd}/tmp/log2.out  
67 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
68 yes
69 wait
70 messages
71 @$out
72 END_OF_DATA
73
74 ################################################################
75 p First :  We just run a full backup and restore
76 ################################################################
77
78 run_bconsole
79 check_for_zombie_jobs storage=File
80
81 check_two_logs
82 check_restore_diff
83
84 rm -rf ${cwd}/tmp/bacula-restores
85
86 ################################################################
87 p Now do a second backup using base backup
88 ################################################################
89
90 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
91 @$out ${cwd}/tmp/log1.out
92 run job=base_backup level=base yes
93 wait
94 messages
95 update volume=TestVolume001 volstatus=Used
96 @$out ${cwd}/tmp/log4.out
97 label volume=TestVolume002 storage=File pool=Default
98 run job=backup level=full yes
99 wait
100 messages
101 @# 
102 @# now do a restore
103 @#
104 @$out ${cwd}/tmp/log2.out  
105 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
106 yes
107 wait
108 messages
109 END_OF_DATA
110
111
112 run_bconsole
113 check_for_zombie_jobs storage=File
114
115 check_two_logs
116 check_restore_diff
117
118 rm -rf ${cwd}/tmp/bacula-restores
119
120 ################################################################
121 p Now do a third backup after making few changes
122 ################################################################
123 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
124 @$out ${cwd}/tmp/log1.out
125 update volume=TestVolume002 volstatus=Used
126 label volume=TestVolume003 storage=File pool=Default
127 run job=backup level=incremental yes
128 wait
129 messages
130 @# 
131 @# now do a restore
132 @#
133 @$out ${cwd}/tmp/log2.out  
134 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
135 yes
136 wait
137 messages
138 END_OF_DATA
139
140 rm ${cwd}/build/accurate/yyyyyy  # delete a file
141 rm -rf ${cwd}/build/accurate/dirtest
142
143
144 run_bconsole
145 check_for_zombie_jobs storage=File
146
147 check_two_logs
148 check_restore_diff
149 check_files_written ${cwd}/tmp/log1.out 4
150
151 rm -rf ${cwd}/tmp/bacula-restores
152
153
154 ################################################################
155 p Test the job purge
156 ################################################################
157 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
158 @$out ${cwd}/tmp/log3.out
159 sql
160 SELECT count(*) FROM BaseFiles;
161
162 purge volume=TestVolume002
163 messages
164 sql
165 SELECT count(*) FROM BaseFiles;
166
167 END_OF_DATA
168
169 run_bconsole
170
171 grep -e ' 0 *|' ${cwd}/tmp/log3.out > /dev/null
172 if [ $? -ne 0 ]; then
173     print_debug "Can't purge the base job"
174     dstat=2
175 fi
176
177 grep -e 'FD Bytes Written: *0' ${cwd}/tmp/log4.out > /dev/null
178 if [ $? -ne 0 ]; then
179     print_debug "The first full job should have 0 byte in log4.out"
180     bstat=2
181 fi
182
183
184 stop_bacula
185 end_test