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