summaryrefslogtreecommitdiff
path: root/rdiff-backup/rdiff_backup/manage.py
diff options
context:
space:
mode:
authorben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2002-05-10 23:14:35 +0000
committerben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2002-05-10 23:14:35 +0000
commit807241bc4f322edc6f95782291900362484263df (patch)
tree95dc93d87081ab901e31844867d4facca6207aac /rdiff-backup/rdiff_backup/manage.py
parent5c059e737511644b0056b8326b52763c82efcac4 (diff)
downloadrdiff-backup-807241bc4f322edc6f95782291900362484263df.tar.gz
Lots of changes, see changelog for 0.7.4.
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@72 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/rdiff_backup/manage.py')
-rw-r--r--rdiff-backup/rdiff_backup/manage.py79
1 files changed, 50 insertions, 29 deletions
diff --git a/rdiff-backup/rdiff_backup/manage.py b/rdiff-backup/rdiff_backup/manage.py
index c0f4a85..0c08872 100644
--- a/rdiff-backup/rdiff_backup/manage.py
+++ b/rdiff-backup/rdiff_backup/manage.py
@@ -12,37 +12,53 @@ class Manage:
"""Return Increments objects given the rdiff-backup data directory"""
return map(IncObj, Manage.find_incrps_with_base(datadir, "increments"))
- def find_incrps_with_base(dir_rp, basename):
- """Return list of incfiles with given basename in dir_rp"""
- rps = map(dir_rp.append, dir_rp.listdir())
- incrps = filter(RPath.isincfile, rps)
- result = filter(lambda rp: rp.getincbase_str() == basename, incrps)
- Log("find_incrps_with_base: found %d incs" % len(result), 6)
- return result
+ def get_file_type(rp):
+ """Returns one of "regular", "directory", "missing", or "special"."""
+ if not rp.lstat(): return "missing"
+ elif rp.isdir(): return "directory"
+ elif rp.isreg(): return "regular"
+ else: return "special"
- def describe_root_incs(datadir):
+ def get_inc_type(inc):
+ """Return file type increment represents"""
+ assert inc.isincfile()
+ type = inc.getinctype()
+ if type == "dir": return "directory"
+ elif type == "diff": return "regular"
+ elif type == "missing": return "missing"
+ elif type == "snapshot": return Manage.get_file_type(inc)
+ else: assert None, "Unknown type %s" % (type,)
+
+ def describe_incs_parsable(incs, mirror_time, mirrorrp):
+ """Return a string parsable by computer describing the increments
+
+ Each line is a time in seconds of the increment, and then the
+ type of the file. It will be sorted oldest to newest. For example:
+
+ 10000 regular
+ 20000 directory
+ 30000 special
+ 40000 missing
+ 50000 regular <- last will be the current mirror
+
+ """
+ incpairs = [(Time.stringtotime(inc.getinctime()), inc) for inc in incs]
+ incpairs.sort()
+ result = ["%s %s" % (time, Manage.get_inc_type(inc))
+ for time, inc in incpairs]
+ result.append("%s %s" % (mirror_time, Manage.get_file_type(mirrorrp)))
+ return "\n".join(result)
+
+ def describe_incs_human(incs, mirror_time, mirrorrp):
"""Return a string describing all the the root increments"""
- result = []
- currentrps = Manage.find_incrps_with_base(datadir, "current_mirror")
- if not currentrps:
- Log("Warning: no current mirror marker found", 1)
- elif len(currentrps) > 1:
- Log("Warning: multiple mirror markers found", 1)
- for rp in currentrps:
- result.append("Found mirror marker %s" % rp.path)
- result.append("Indicating latest mirror taken at %s" %
- Time.stringtopretty(rp.getinctime()))
- result.append("---------------------------------------------"
- "-------------")
-
- # Sort so they are in reverse order by time
- time_w_incobjs = map(lambda io: (-io.time, io),
- Manage.get_incobjs(datadir))
- time_w_incobjs.sort()
- incobjs = map(lambda x: x[1], time_w_incobjs)
- result.append("Found %d increments:" % len(incobjs))
- result.append("\n------------------------------------------\n".join(
- map(IncObj.full_description, incobjs)))
+ incpairs = [(Time.stringtotime(inc.getinctime()), inc) for inc in incs]
+ incpairs.sort()
+
+ result = ["Found %d increments:" % len(incpairs)]
+ for time, inc in incpairs:
+ result.append(" %s %s" %
+ (inc.dirsplit()[1], Time.timetopretty(time)))
+ result.append("Current mirror: %s" % Time.timetopretty(mirror_time))
return "\n".join(result)
def delete_earlier_than(baserp, time):
@@ -53,6 +69,11 @@ class Manage:
rdiff-backup-data directory should be the root of the tree.
"""
+ baserp.conn.Manage.delete_earlier_than_local(baserp, time)
+
+ def delete_earlier_than_local(baserp, time):
+ """Like delete_earlier_than, but run on local connection for speed"""
+ assert baserp.conn is Globals.local_connection
def yield_files(rp):
yield rp
if rp.isdir():