projects
/
cumulus.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Start on a tool to rebuild the local database if it is lost.
[cumulus.git]
/
python
/
cumulus
/
retention.py
diff --git
a/python/cumulus/retention.py
b/python/cumulus/retention.py
index
e89263a
..
b0e0078
100644
(file)
--- a/
python/cumulus/retention.py
+++ b/
python/cumulus/retention.py
@@
-1,7
+1,6
@@
-# Cumulus: Smart Filesystem Backup to Dumb Servers
-#
-# Copyright (C) 2012 Google Inc.
-# Written by Michael Vrable <mvrable@cs.ucsd.edu>
+# Cumulus: Efficient Filesystem Backup to the Cloud
+# Copyright (C) 2012 The Cumulus Developers
+# See the AUTHORS file for a list of contributors.
#
# 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
#
# 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
@@
-103,10
+102,12
@@
class RetentionEngine(object):
def add_policy(self, backup_class, retention_period):
self._policies[backup_class] = retention_period
def add_policy(self, backup_class, retention_period):
self._policies[backup_class] = retention_period
- self._last_snapshots[backup_class] = (None, None)
+ self._last_snapshots[backup_class] = (None, None
, False
)
@staticmethod
def parse_timestamp(s):
@staticmethod
def parse_timestamp(s):
+ if isinstance(s, datetime.datetime):
+ return s
return datetime.datetime.strptime(s, TIMESTAMP_FORMAT)
def consider_snapshot(self, snapshot):
return datetime.datetime.strptime(s, TIMESTAMP_FORMAT)
def consider_snapshot(self, snapshot):
@@
-135,9
+136,11
@@
class RetentionEngine(object):
partition = _backup_classes[backup_class](timestamp_policy)
last_snapshot = self._last_snapshots[backup_class]
if self._last_snapshots[backup_class][0] != partition:
partition = _backup_classes[backup_class](timestamp_policy)
last_snapshot = self._last_snapshots[backup_class]
if self._last_snapshots[backup_class][0] != partition:
- self._last_snapshots[backup_class] = (partition, snapshot)
self._labels.add(backup_class)
self._labels.add(backup_class)
- if snapshot_age < retention_period: retain = True
+ retain_label = snapshot_age < retention_period
+ self._last_snapshots[backup_class] = (partition, snapshot,
+ retain_label)
+ if retain_label: retain = True
return retain
def last_labels(self):
return retain
def last_labels(self):
@@
-149,4
+152,5
@@
class RetentionEngine(object):
def last_snapshots(self):
"""Returns the most recent snapshot in each backup class."""
def last_snapshots(self):
"""Returns the most recent snapshot in each backup class."""
- return dict((k, v[1]) for (k, v) in self._last_snapshots.iteritems())
+ return dict((k, v[1]) for (k, v)
+ in self._last_snapshots.iteritems() if v[2])