]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/prune-base-job-test
regress: Add a deleted file test for restart
[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 quit
91 END_OF_DATA
92
93
94 run_bconsole
95 check_for_zombie_jobs storage=File
96
97 check_two_logs
98 check_restore_diff
99
100 export bstat dstat estat
101
102 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
103 @$out ${cwd}/tmp/log4.out
104 @exec "touch $cwd/build/po/fr.po"
105 run job=backup level=incremental yes
106 wait
107 messages
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/log1.out
132 @################################################################
133 @# This full job will force the purge of the previous one
134 run job=backup level=full yes
135 wait
136 messages
137 @$out $tmp/log13.out
138 list jobs
139 prune jobs yes
140 list jobs
141 @$out $tmp/log1.out
142 @################################################################
143 @# see with two base jobs (base_backup and backup)
144 run job=backup level=base yes
145 wait
146 messages
147 @exec "touch $cwd/bin/bacula-dir.conf"
148 run job=base_backup level=base yes
149 wait
150 messages
151 list jobs
152 run job=backup level=full yes
153 wait
154 messages
155 list jobs
156 @$out $tmp/log14.out
157 list jobs
158 prune jobs yes
159 list jobs
160 END_OF_DATA
161
162 run_bconsole
163
164 # Now we will verify that the pruning code is working as expected.  Each time,
165 # we run 'list jobs', 'prune', 'list jobs'. check_prune_list ensures that jobids
166 # in argument are present in the first 'list jobs', the 'prune' command deletes
167 # them (same number), and checks that the last 'list jobs' doesn't contain them
168 # anymore. See scripts/functions.pm for details.
169
170 # B F I D I0 R I -> B F D I
171 $bperl -e "check_prune_list('$tmp/log10.out', 3,5,6)"
172 estat=$(($estat + $?))
173
174 # B F D I F -> B F
175 $bperl -e "check_prune_list('$tmp/log11.out', 2,4,7)"
176 estat=$(($estat + $?))
177
178 # B F B F -> B F
179 $bperl -e "check_prune_list('$tmp/log13.out',1,8)"
180 estat=$(($estat + $?))
181
182 # B F B B F -> B B F
183 $bperl -e "check_prune_list('$tmp/log14.out',9,10)"
184 estat=$(($estat + $?))
185
186 stop_bacula
187 end_test