]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/base-job-test
check for purge job
[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 label volume=TestVolume002 storage=File pool=Default
97 run job=backup level=full yes
98 wait
99 messages
100 @# 
101 @# now do a restore
102 @#
103 @$out ${cwd}/tmp/log2.out  
104 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
105 yes
106 wait
107 messages
108 END_OF_DATA
109
110
111 run_bconsole
112 check_for_zombie_jobs storage=File
113
114 check_two_logs
115 check_restore_diff
116
117 rm -rf ${cwd}/tmp/bacula-restores
118
119 ################################################################
120 p Now do a third backup after making few changes
121 ################################################################
122 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
123 @$out ${cwd}/tmp/log1.out
124 update volume=TestVolume002 volstatus=Used
125 label volume=TestVolume003 storage=File pool=Default
126 run job=backup level=incremental yes
127 wait
128 messages
129 @# 
130 @# now do a restore
131 @#
132 @$out ${cwd}/tmp/log2.out  
133 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
134 yes
135 wait
136 messages
137 END_OF_DATA
138
139 rm ${cwd}/build/accurate/yyyyyy  # delete a file
140 rm -rf ${cwd}/build/accurate/dirtest
141
142
143 run_bconsole
144 check_for_zombie_jobs storage=File
145
146 check_two_logs
147 check_restore_diff
148 check_files_written ${cwd}/tmp/log1.out 4
149
150 rm -rf ${cwd}/tmp/bacula-restores
151
152
153 ################################################################
154 p Test the job purge
155 ################################################################
156 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
157 @$out ${cwd}/tmp/log3.out
158 sql
159 SELECT count(*) FROM BaseFiles;
160
161 purge volume=TestVolume002
162 messages
163 sql
164 SELECT count(*) FROM BaseFiles;
165
166 END_OF_DATA
167
168 run_bconsole
169
170 grep -e ' 0 *|' ${cwd}/tmp/log3.out > /dev/null
171 if [ $? -ne 0 ]; then
172     print_debug "Can't purge the base job"
173     dstat=2
174 fi
175
176 stop_bacula
177 end_test