This repository has been archived by the owner on Mar 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
prune-base-job-test
executable file
·187 lines (160 loc) · 4.44 KB
/
prune-base-job-test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#!/bin/sh
#
# Run a basejob backup of the Bareos build directory
# then restore it.
#
TestName="prune-base-job-test"
JobName=backup
. scripts/functions
$rscripts/cleanup
copy_test_confs
echo 's/backup_advance/base_backup/' > $tmp/s
echo 's/Name = backup/Name = backup; Base = base_backup, backup/' >> $tmp/s
sed -f $tmp/s $rscripts/bareos-dir.conf.accurate > $conf/bareos-dir.conf
rm -f $tmp/s
sed s/all,/all,saved,/ $conf/bareos-fd.conf > tmp/1
cp tmp/1 $conf/bareos-fd.conf
change_jobname BackupClient1 $JobName
dircfg=$conf/bareos-dir.conf
# modify some attributes in configuration file for the test
$bperl -e "add_attribute('$dircfg', 'AutoPrune', 'No', 'Client')"
$bperl -e "add_attribute('$dircfg', 'Job Retention', '1s', 'Client')"
$bperl -e "add_attribute('$dircfg', 'File', '<$tmp/lst', 'FileSet', 'FS_TESTJOB_ADVANCE')"
p() {
echo "##############################################" >> ${cwd}/tmp/log1.out
echo "$*" >> ${cwd}/tmp/log1.out
echo "##############################################" >> ${cwd}/tmp/log2.out
echo "$*" >> ${cwd}/tmp/log2.out
}
echo ${cwd}/bin > ${cwd}/tmp/lst
echo ${cwd}/bin > ${cwd}/tmp/file-list
echo ${cwd}/build >> ${cwd}/tmp/file-list
start_test
cat <<END_OF_DATA >${cwd}/tmp/bconcmds
@output /dev/null
messages
label volume=TestVolume001 storage=File pool=Default
messages
END_OF_DATA
run_bareos
################################################################
p Now do a backup using base backup
################################################################
cat <<END_OF_DATA >${cwd}/tmp/bconcmds
@$out ${cwd}/tmp/log1.out
run job=base_backup level=base yes
wait
messages
update volume=TestVolume001 volstatus=Used
END_OF_DATA
run_bconsole
cat <<END_OF_DATA >${cwd}/tmp/bconcmds
@$out $tmp/log4.out
label volume=TestVolume002 storage=File pool=Default
run job=backup level=full yes
wait
messages
@exec "touch $cwd/build/po/fr.po"
run job=backup level=incremental yes
wait
messages
run job=backup level=differential yes
wait
messages
@# should be empty
run job=backup level=incremental yes
wait
messages
@$out $tmp/log2.out
@#
@# now do a restore
@#
restore fileset=FS_TESTJOB where=${cwd}/tmp/bareos-restores select all done
yes
wait
messages
quit
END_OF_DATA
run_bconsole
check_for_zombie_jobs storage=File
check_two_logs
check_restore_diff
export bstat dstat estat
cat <<END_OF_DATA >${cwd}/tmp/bconcmds
@$out ${cwd}/tmp/log4.out
@exec "touch $cwd/build/po/fr.po"
run job=backup level=incremental yes
wait
messages
@$out $tmp/log10.out
sql
SELECT count(*) FROM BaseFiles;
list jobs
prune jobs jobtype=backup yes
list jobs
@$out $tmp/log1.out
@################################################################
@# This full job will force the purge of the previous one
run job=backup level=full yes
wait
messages
@$out $tmp/log11.out
list jobs
prune jobs jobtype=backup yes
list jobs
@$out $tmp/log1.out
@################################################################
@# This base job will replace the first one after the next full replacement
run job=base_backup level=base yes
wait
messages
@$out $tmp/log1.out
@################################################################
@# This full job will force the purge of the previous one
run job=backup level=full yes
wait
messages
@$out $tmp/log13.out
list jobs
prune jobs jobtype=backup yes
list jobs
@$out $tmp/log1.out
@################################################################
@# see with two base jobs (base_backup and backup)
run job=backup level=base yes
wait
messages
@exec "touch $cwd/bin/bareos-dir.conf"
run job=base_backup level=base yes
wait
messages
list jobs
run job=backup level=full yes
wait
messages
list jobs
@$out $tmp/log14.out
list jobs
prune jobs jobtype=backup yes
list jobs
END_OF_DATA
run_bconsole
# Now we will verify that the pruning code is working as expected. Each time,
# we run 'list jobs', 'prune', 'list jobs'. check_prune_list ensures that jobids
# in argument are present in the first 'list jobs', the 'prune' command deletes
# them (same number), and checks that the last 'list jobs' doesn't contain them
# anymore. See scripts/functions.pm for details.
# B F I D I0 R I -> B F D I
$bperl -e "check_prune_list('$tmp/log10.out', 3,5,6)"
estat=$(($estat + $?))
# B F D I F -> B F
$bperl -e "check_prune_list('$tmp/log11.out', 2,4,7)"
estat=$(($estat + $?))
# B F B F -> B F
$bperl -e "check_prune_list('$tmp/log13.out',1,8)"
estat=$(($estat + $?))
# B F B B F -> B B F
$bperl -e "check_prune_list('$tmp/log14.out',9,10)"
estat=$(($estat + $?))
stop_bareos
end_test