minor terminology change
This commit is contained in:
parent
8e7841b4cc
commit
407eeb2d1b
26
backup.py
26
backup.py
@ -46,7 +46,15 @@ loglvls = {'critical': logging.CRITICAL,
|
||||
dflt_ns = 'http://git.root2.io/r00t2/borgextend/'
|
||||
|
||||
# In code, replace "day" with "daily" when constructing command.
|
||||
policyperiods = ('Second', 'Minute', 'Hour', 'Day', 'Week', 'Month', 'Year')
|
||||
policyperiods = (
|
||||
('seconds', 'secondly'),
|
||||
('minutes', 'minutely'),
|
||||
('hours', 'hourly'),
|
||||
('days', 'daily'),
|
||||
('weeks', 'weekly'),
|
||||
('months', 'monthly'),
|
||||
('years', 'yearly'),
|
||||
)
|
||||
|
||||
### THE GUTS ###
|
||||
class Backup(object):
|
||||
@ -170,14 +178,13 @@ class Backup(object):
|
||||
r['retention']['last'] = isodate.parse_duration(keepWithin.text)
|
||||
keepLast = repo.find('{0}keepLast'.format(self.ns))
|
||||
if keepLast is not None:
|
||||
for e in policyperiods:
|
||||
k = e.lower()
|
||||
policy = keepLast.find('{0}per{1}'.format(self.ns, e))
|
||||
for e, _ in policyperiods:
|
||||
policy = keepLast.find('{0}{1}'.format(self.ns, e))
|
||||
if policy is not None:
|
||||
if 'retention' not in r.keys():
|
||||
r['retention'] = {}
|
||||
# This is safe. We validate the config.
|
||||
r['retention'][k] = int(policy.text)
|
||||
r['retention'][e] = int(policy.text)
|
||||
repos.append(r)
|
||||
return(repos)
|
||||
self.logger.debug('VARS (before args cleanup): {0}'.format(vars(self)))
|
||||
@ -514,12 +521,9 @@ class Backup(object):
|
||||
retentionSeconds = repo['retention'].totimedelta(datetime.datetime.now()).total_seconds()
|
||||
_cmd.extend(['--keep-within', '{0}H'.format(retentionSeconds / 60)])
|
||||
# keepLast
|
||||
for e in policyperiods:
|
||||
if repo['retention'].get(e.lower()) is not None:
|
||||
a = e.lower() + 'ly'
|
||||
if e.lower() == 'day':
|
||||
a = 'daily'
|
||||
_cmd.extend(['--keep-{0}'.format(a), repo['retention'][e.lower()]])
|
||||
for e, a in policyperiods:
|
||||
if repo['retention'].get(e, 0) is not 0:
|
||||
_cmd.extend(['--keep-{0}'.format(a), repo['retention'][e]])
|
||||
if self.repos[server]['remote'].lower()[0] in ('1', 't'):
|
||||
repo_tgt = '{0}@{1}'.format(_user, server)
|
||||
else:
|
||||
|
14
config.xsd
14
config.xsd
@ -64,13 +64,13 @@
|
||||
<xs:element name="keepLast" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:choice minOccurs="1" maxOccurs="7">
|
||||
<xs:element name="perSecond" minOccurs="0" maxOccurs="1" type="xs:positiveInteger"/>
|
||||
<xs:element name="perMinute" minOccurs="0" maxOccurs="1" type="xs:positiveInteger"/>
|
||||
<xs:element name="perHour" minOccurs="0" maxOccurs="1" type="xs:positiveInteger"/>
|
||||
<xs:element name="perDay" minOccurs="0" maxOccurs="1" type="xs:positiveInteger"/>
|
||||
<xs:element name="perWeek" minOccurs="0" maxOccurs="1" type="xs:positiveInteger"/>
|
||||
<xs:element name="perMonth" minOccurs="0" maxOccurs="1" type="xs:positiveInteger"/>
|
||||
<xs:element name="perYear" minOccurs="0" maxOccurs="1" type="xs:positiveInteger"/>
|
||||
<xs:element name="seconds" minOccurs="0" maxOccurs="1" type="xs:positiveInteger"/>
|
||||
<xs:element name="minutes" minOccurs="0" maxOccurs="1" type="xs:positiveInteger"/>
|
||||
<xs:element name="hours" minOccurs="0" maxOccurs="1" type="xs:positiveInteger"/>
|
||||
<xs:element name="days" minOccurs="0" maxOccurs="1" type="xs:positiveInteger"/>
|
||||
<xs:element name="weeks" minOccurs="0" maxOccurs="1" type="xs:positiveInteger"/>
|
||||
<xs:element name="months" minOccurs="0" maxOccurs="1" type="xs:positiveInteger"/>
|
||||
<xs:element name="years" minOccurs="0" maxOccurs="1" type="xs:positiveInteger"/>
|
||||
</xs:choice>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
@ -41,12 +41,12 @@
|
||||
<keepWithin>P1MT2M30S</keepWithin>
|
||||
<!--
|
||||
keepLast specifies a *policy* for retention.
|
||||
It can be used to specify explicit "N archives per Y". For example, the below retains the first
|
||||
archive for each month (going back 2 months), and the first archive each year for the last three years.
|
||||
It can be used to specify explicit "N archives per Y period type". For example, the below retains the last
|
||||
archive for each month (going back 2 months), and the last archive each year for the last three years.
|
||||
-->
|
||||
<keepLast>
|
||||
<perMonth>2</perMonth>
|
||||
<perYear>3</perYear>
|
||||
<months>2</months>
|
||||
<years>3</years>
|
||||
</keepLast>
|
||||
<!--
|
||||
Each path entry is a path to back up.
|
||||
|
Loading…
Reference in New Issue
Block a user