]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/prune-base-job-test
bacula-web: Modified layout for main dashboard
[bacula/bacula] / regress / tests / prune-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="prune-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 dircfg=$conf/bacula-dir.conf
23
24 # modify some attributes in configuration file for the test
25 $bperl -e "add_attribute('$dircfg', 'AutoPrune', 'No', 'Client')"
26 $bperl -e "add_attribute('$dircfg', 'Job Retention', '1s', 'Client')"
27 $bperl -e "add_attribute('$dircfg', 'File', '<$tmp/lst', 'FileSet', 'FS_TESTJOB_ADVANCE')"
28 p() {
29     echo "##############################################" >> ${cwd}/tmp/log1.out
30     echo "$*" >> ${cwd}/tmp/log1.out
31     echo "##############################################" >> ${cwd}/tmp/log2.out
32     echo "$*" >> ${cwd}/tmp/log2.out
33 }
34
35
36 echo ${cwd}/bin > ${cwd}/tmp/lst
37 echo ${cwd}/bin > ${cwd}/tmp/file-list
38 echo ${cwd}/build >> ${cwd}/tmp/file-list
39
40 start_test
41
42 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
43 @output /dev/null
44 messages
45 label volume=TestVolume001 storage=File pool=Default
46 messages
47 END_OF_DATA
48
49 run_bacula
50
51 ################################################################
52 p Now do a backup using base backup
53 ################################################################
54
55 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
56 @$out ${cwd}/tmp/log1.out
57 run job=base_backup level=base yes
58 wait
59 messages
60 update volume=TestVolume001 volstatus=Used
61 END_OF_DATA
62
63 run_bconsole
64
65 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
66 @$out $tmp/log4.out
67 label volume=TestVolume002 storage=File pool=Default
68 run job=backup level=full yes
69 wait
70 messages
71 @exec "touch $cwd/build/po/fr.po"
72 run job=backup level=incremental yes
73 wait
74 messages
75 run job=backup level=differential yes
76 wait
77 messages
78 @# should be empty
79 run job=backup level=incremental yes
80 wait
81 messages
82 @$out $tmp/log2.out
83 @# 
84 @# now do a restore
85 @#
86 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
87 yes
88 wait
89 messages
90 @$out ${cwd}/tmp/log4.out
91 @exec "touch $cwd/build/po/fr.po"
92 run job=backup level=incremental yes
93 wait
94 messages
95 quit
96 END_OF_DATA
97
98
99 run_bconsole
100 check_for_zombie_jobs storage=File
101
102 check_two_logs
103 check_restore_diff
104
105 export bstat dstat estat
106
107 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
108 @$out $tmp/log10.out
109 sql
110 SELECT count(*) FROM BaseFiles;
111
112 list jobs
113 prune jobs yes
114 list jobs
115 @$out $tmp/log1.out
116 @################################################################
117 @# This full job will force the purge of the previous one
118 run job=backup level=full yes
119 wait
120 messages
121 @$out $tmp/log11.out
122 list jobs
123 prune jobs yes
124 list jobs
125 @$out $tmp/log1.out
126 @################################################################
127 @# This base job will replace the first one after the next full replacement
128 run job=base_backup level=base yes
129 wait
130 messages
131 @$out $tmp/log12.out
132 list jobs
133 prune jobs yes
134 list jobs
135 @$out $tmp/log1.out
136 @################################################################
137 @# This full job will force the purge of the previous one
138 run job=backup level=full yes
139 wait
140 messages
141 @$out $tmp/log13.out
142 list jobs
143 prune jobs yes
144 list jobs
145 @$out $tmp/log1.out
146 @################################################################
147 @# see with two base jobs (base_backup and backup)
148 run job=backup level=base yes
149 wait
150 messages
151 @exec "touch $cwd/bin/bacula-dir.conf"
152 run job=base_backup level=base yes
153 wait
154 messages
155 list jobs
156 run job=backup level=full yes
157 wait
158 messages
159 list jobs
160 @$out $tmp/log14.out
161 list jobs
162 prune jobs yes
163 list jobs
164 END_OF_DATA
165
166 run_bconsole
167
168 # Now we will verify that the pruning code is working as expected.  Each time,
169 # we run 'list jobs', 'prune', 'list jobs'. check_prune_list ensures that jobids
170 # in argument are present in the first 'list jobs', the 'prune' command deletes
171 # them (same number), and checks that the last 'list jobs' doesn't contain them
172 # anymore. See scripts/functions.pm for details.
173
174 # B F I D I0 R I -> B F D I
175 $bperl -e "check_prune_list('$tmp/log10.out', 3,5,6)"
176 estat=$(($estat + $?))
177
178 # B F D I F -> B F
179 $bperl -e "check_prune_list('$tmp/log11.out', 2,4,7)"
180 estat=$(($estat + $?))
181
182 # B F B -> B F B
183 $bperl -e "check_prune_list('$tmp/log12.out')"
184 estat=$(($estat + $?))
185
186 # B F B F -> B F
187 $bperl -e "check_prune_list('$tmp/log13.out',1,8)"
188 estat=$(($estat + $?))
189
190 # B F B B F -> B B F
191 $bperl -e "check_prune_list('$tmp/log14.out',9,10)"
192 estat=$(($estat + $?))
193
194 stop_bacula
195 end_test