File: prunedecay

package info (click to toggle)
rsbackup 10.0-4
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 1,908 kB
  • sloc: cpp: 10,859; sh: 2,566; makefile: 387; perl: 11
file content (182 lines) | stat: -rwxr-xr-x 8,165 bytes parent folder | download | duplicates (3)
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
#! /bin/sh
# Copyright © 2015 Richard Kettlewell.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
set -e
PRUNE_POLICY=decay
DECAY_LIMIT=8d
. ${srcdir:-.}/setup.sh

setup

# With the default configuration the buckets look like this:
# 0/1 days old - with decay-start
# 2 days old - B0
# 3/4 days old - B1
# 5-8 days old - B2

echo "| Day 1"
RSBACKUP_TIME=315532800 s ${RSBACKUP} --backup host1:volume1
RSBACKUP_TIME=315532800 s ${RSBACKUP} --prune
# D1, 0 days old, within decay-start
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-01T00:00:00

echo "| Day 2"
RSBACKUP_TIME=315619200 s ${RSBACKUP} --backup host1:volume1
RSBACKUP_TIME=315619200 s ${RSBACKUP} --prune
# D1, 1 days old, within decay-start
# D2, 0 days old, within decay-start
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-01T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-02T00:00:00

echo "| Day 3"
RSBACKUP_TIME=315705600 s ${RSBACKUP} --backup host1:volume1
RSBACKUP_TIME=315705600 s ${RSBACKUP} --prune
# D1, 2 days old, in B0
# D2, 1 days old, within decay-start
# D3, 0 days old, within decay-start
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-01T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-02T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-03T00:00:00

echo "| Day 4"
RSBACKUP_TIME=315792000 s ${RSBACKUP} --backup host1:volume1
RSBACKUP_TIME=315792000 s ${RSBACKUP} --prune
# D1, 3 days old, in B1
# D2, 2 days old, in B0
# D3, 1 days old, within decay-start
# D4, 0 days old, within decay-start
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-01T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-02T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-03T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-04T00:00:00

echo "| Day 5"
RSBACKUP_TIME=315878400 s ${RSBACKUP} --backup host1:volume1
RSBACKUP_TIME=315878400 s ${RSBACKUP} --prune
# D1, 4 days old, in B1
# D2, 3 days old, in B1, not oldest, prunable
# D3, 2 days old, in B0
# D4, 1 days old, within decay-start
# D5, 0 days old, within decay-start
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-01T00:00:00
absent ${WORKSPACE}/store1/host1/volume1/1980-01-02
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-03T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-04T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-05T00:00:00

echo "| Day 6"
RSBACKUP_TIME=315964800 s ${RSBACKUP} --backup host1:volume1
RSBACKUP_TIME=315964800 s ${RSBACKUP} --prune
# D1, 5 days old, in B2
# (D2 gone)
# D3, 3 days old, in B1
# D4, 2 days old, in B0
# D5, 1 days old, within decay-start
# D6, 0 days old, within decay-start
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-01T00:00:00
absent ${WORKSPACE}/store1/host1/volume1/1980-01-02T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-03T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-04T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-05T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-06T00:00:00

echo "| Day 7"
RSBACKUP_TIME=316051200 s ${RSBACKUP} --backup host1:volume1
RSBACKUP_TIME=316051200 s ${RSBACKUP} --prune
# D1, 6 days old, in B2
# (D2 gone)
# D3, 4 days old, in B1
# D4, 3 days old, in B1, not oldest, prunable
# D5, 2 days old, in B0
# D6, 1 days old, within decay-start
# D7, 0 days old, within decay-start
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-01T00:00:00
absent ${WORKSPACE}/store1/host1/volume1/1980-01-02T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-03T00:00:00
absent ${WORKSPACE}/store1/host1/volume1/1980-01-04T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-05T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-06T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-07T00:00:00

echo "| Day 8"
RSBACKUP_TIME=316137600 s ${RSBACKUP} --backup host1:volume1
RSBACKUP_TIME=316137600 s ${RSBACKUP} --prune
# D1, 7 days old, in B2
# (D2 gone)
# D3, 5 days old, in B2, not oldest, prunable
# (D4 gone)
# D5, 3 days old, in B1
# D6, 2 days old, in B0
# D7, 1 days old, within decay-start
# D8, 0 days old, within decay-start
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-01T00:00:00
absent ${WORKSPACE}/store1/host1/volume1/1980-01-02T00:00:00
absent ${WORKSPACE}/store1/host1/volume1/1980-01-03T00:00:00
absent ${WORKSPACE}/store1/host1/volume1/1980-01-04T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-05T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-06T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-07T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-08T00:00:00

echo "| Day 9"
RSBACKUP_TIME=316224000 s ${RSBACKUP} --backup host1:volume1
RSBACKUP_TIME=316224000 s ${RSBACKUP} --prune
# D1, 8 days old, in B2
# (D2 gone)
# (D3 gone)
# (D4 gone)
# D5, 4 days old, in B1
# D6, 3 days old, in B1, not oldest, prunable
# D7, 2 days old, in B0
# D8, 1 days old, within decay-start
# D9, 0 days old, within decay-start
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-01T00:00:00
absent ${WORKSPACE}/store1/host1/volume1/1980-01-02T00:00:00
absent ${WORKSPACE}/store1/host1/volume1/1980-01-03T00:00:00
absent ${WORKSPACE}/store1/host1/volume1/1980-01-04T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-05T00:00:00
absent ${WORKSPACE}/store1/host1/volume1/1980-01-06T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-07T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-08T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-09T00:00:00

echo "| Day 10"
RSBACKUP_TIME=316310400 s ${RSBACKUP} --backup host1:volume1
RSBACKUP_TIME=316310400 s ${RSBACKUP} --prune
# D1, 9 days old, in B3, beyond decay-limit, prunable
# (D2 gone)
# (D3 gone)
# (D4 gone)
# D5, 5 days old, in B2
# (D6 gone)
# D7, 3 days old, in B1
# D8, 2 days old, in B0
# D9, 1 days old, within decay-start
# D10, 0 days old, within decay-start
absent ${WORKSPACE}/store1/host1/volume1/1980-01-01T00:00:00
absent ${WORKSPACE}/store1/host1/volume1/1980-01-02T00:00:00
absent ${WORKSPACE}/store1/host1/volume1/1980-01-03T00:00:00
absent ${WORKSPACE}/store1/host1/volume1/1980-01-04T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-05T00:00:00
absent ${WORKSPACE}/store1/host1/volume1/1980-01-06T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-07T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-08T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-09T00:00:00
compare ${WORKSPACE}/volume1 ${WORKSPACE}/store1/host1/volume1/1980-01-10T00:00:00

sqlite3 ${WORKSPACE}/logs/backups.db "SELECT host,volume,device,id,rc,status,time,pruned,log FROM backup WHERE pruned != 0" > ${WORKSPACE}/got/prunedecay-db.txt
compare ${srcdir:-.}/expect/prunedecay/prunedecay-db.txt ${WORKSPACE}/got/prunedecay-db.txt

cleanup