]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/prune-base-job-test
Attempt to fix timing problem with console-dotcmd-test on FreeBSD
[bacula/bacula] / regress / tests / prune-base-job-test
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6
7 #
8 # Run a basejob backup of the Bacula build directory
9 #   then restore it.
10 #
11
12 TestName="prune-base-job-test"
13 JobName=backup
14 . scripts/functions
15 $rscripts/cleanup
16
17 copy_test_confs
18 echo 's/backup_advance/base_backup/' > $tmp/s
19 echo 's/Name = backup/Name = backup; Base = base_backup, backup/' >> $tmp/s
20 sed -f $tmp/s $rscripts/bacula-dir.conf.accurate > $conf/bacula-dir.conf
21 rm -f $tmp/s
22
23 sed s/all,/all,saved,/ $conf/bacula-fd.conf > tmp/1
24 cp tmp/1 $conf/bacula-fd.conf
25
26 change_jobname BackupClient1 $JobName
27 dircfg=$conf/bacula-dir.conf
28
29 # modify some attributes in configuration file for the test
30 $bperl -e "add_attribute('$dircfg', 'AutoPrune', 'No', 'Client')"
31 $bperl -e "add_attribute('$dircfg', 'Job Retention', '1s', 'Client')"
32 $bperl -e "add_attribute('$dircfg', 'File', '<$tmp/lst', 'FileSet', 'FS_TESTJOB_ADVANCE')"
33 p() {
34     echo "##############################################" >> ${cwd}/tmp/log1.out
35     echo "$*" >> ${cwd}/tmp/log1.out
36     echo "##############################################" >> ${cwd}/tmp/log2.out
37     echo "$*" >> ${cwd}/tmp/log2.out
38 }
39
40
41 echo ${cwd}/bin > ${cwd}/tmp/lst
42 echo ${cwd}/bin > ${cwd}/tmp/file-list
43 echo ${cwd}/build >> ${cwd}/tmp/file-list
44
45 start_test
46
47 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
48 @output /dev/null
49 messages
50 label volume=TestVolume001 storage=File pool=Default
51 messages
52 END_OF_DATA
53
54 run_bacula
55
56 ################################################################
57 p Now do a backup using base backup
58 ################################################################
59
60 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
61 @$out ${cwd}/tmp/log1.out
62 run job=base_backup level=base yes
63 wait
64 messages
65 update volume=TestVolume001 volstatus=Used
66 END_OF_DATA
67
68 run_bconsole
69
70 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
71 @$out $tmp/log4.out
72 label volume=TestVolume002 storage=File pool=Default
73 run job=backup level=full yes
74 wait
75 messages
76 @exec "touch $cwd/build/po/fr.po"
77 run job=backup level=incremental yes
78 wait
79 messages
80 run job=backup level=differential yes
81 wait
82 messages
83 @# should be empty
84 run job=backup level=incremental yes
85 wait
86 messages
87 @$out $tmp/log2.out
88 @# 
89 @# now do a restore
90 @#
91 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
92 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 ${cwd}/tmp/log4.out
109 @exec "touch $cwd/build/po/fr.po"
110 run job=backup level=incremental yes
111 wait
112 messages
113 @$out $tmp/log10.out
114 sql
115 SELECT count(*) FROM BaseFiles;
116
117 list jobs
118 prune jobs yes
119 list jobs
120 @$out $tmp/log1.out
121 @################################################################
122 @# This full job will force the purge of the previous one
123 run job=backup level=full yes
124 wait
125 messages
126 @$out $tmp/log11.out
127 list jobs
128 prune jobs yes
129 list jobs
130 @$out $tmp/log1.out
131 @################################################################
132 @# This base job will replace the first one after the next full replacement
133 run job=base_backup level=base yes
134 wait
135 messages
136 @$out $tmp/log1.out
137 @################################################################
138 @# This full job will force the purge of the previous one
139 run job=backup level=full yes
140 wait
141 messages
142 @$out $tmp/log13.out
143 list jobs
144 prune jobs yes
145 list jobs
146 @$out $tmp/log1.out
147 @################################################################
148 @# see with two base jobs (base_backup and backup)
149 run job=backup level=base yes
150 wait
151 messages
152 @exec "touch $cwd/bin/bacula-dir.conf"
153 run job=base_backup level=base yes
154 wait
155 messages
156 list jobs
157 run job=backup level=full yes
158 wait
159 messages
160 list jobs
161 @$out $tmp/log14.out
162 list jobs
163 prune jobs yes
164 list jobs
165 END_OF_DATA
166
167 run_bconsole
168
169 # Now we will verify that the pruning code is working as expected.  Each time,
170 # we run 'list jobs', 'prune', 'list jobs'. check_prune_list ensures that jobids
171 # in argument are present in the first 'list jobs', the 'prune' command deletes
172 # them (same number), and checks that the last 'list jobs' doesn't contain them
173 # anymore. See scripts/functions.pm for details.
174
175 # B F I D I0 R I -> B F D I
176 $bperl -e "check_prune_list('$tmp/log10.out', 3,5,6)"
177 estat=$(($estat + $?))
178
179 # B F D I F -> B F
180 $bperl -e "check_prune_list('$tmp/log11.out', 2,4,7)"
181 estat=$(($estat + $?))
182
183 # B F B F -> B F
184 $bperl -e "check_prune_list('$tmp/log13.out',1,8)"
185 estat=$(($estat + $?))
186
187 # B F B B F -> B B F
188 $bperl -e "check_prune_list('$tmp/log14.out',9,10)"
189 estat=$(($estat + $?))
190
191 stop_bacula
192 end_test