diff options
author | bescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2005-11-24 05:07:09 +0000 |
---|---|---|
committer | bescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2005-11-24 05:07:09 +0000 |
commit | da3cdf9df0177e72f0b89246eff7e17ff58e4477 (patch) | |
tree | d4d4b89000ba82b66a58f9821060b65690e32aa6 /rdiff-backup/rdiff_backup | |
parent | 559b413a54f2e6c33347f9f1dc97b8c84880eb1d (diff) | |
download | rdiff-backup-da3cdf9df0177e72f0b89246eff7e17ff58e4477.tar.gz |
Remove older than overenthusiastic deletion fix
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/branches/r1-0@689 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/rdiff_backup')
-rw-r--r-- | rdiff-backup/rdiff_backup/Main.py | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/rdiff-backup/rdiff_backup/Main.py b/rdiff-backup/rdiff_backup/Main.py index 1b46d1e..fc3142c 100644 --- a/rdiff-backup/rdiff_backup/Main.py +++ b/rdiff-backup/rdiff_backup/Main.py @@ -757,17 +757,24 @@ def RemoveOlderThan(rootrp): """Remove all increment files older than a certain time""" rootrp = require_root_set(rootrp) rot_require_rbdir_base(rootrp) - try: time = Time.genstrtotime(remove_older_than_string) + + time = rot_check_time(remove_older_than_string) + if time is None: return + Log("Actual remove older than time: %s" % (time,), 6) + manage.delete_earlier_than(Globals.rbdir, time) + +def rot_check_time(time_string): + """Check remove older than time_string, return time in seconds""" + try: time = Time.genstrtotime(time_string) except Time.TimeException, exc: Log.FatalError(str(exc)) - timep = Time.timetopretty(time) - Log("Deleting increment(s) before %s" % timep, 4) times_in_secs = [inc.getinctime() for inc in restore.get_inclist(Globals.rbdir.append_path("increments"))] times_in_secs = filter(lambda t: t < time, times_in_secs) if not times_in_secs: - Log.FatalError("No increments older than %s found, exiting." - % (timep,), 1, errlevel = 0) + Log("No increments older than %s found, exiting." % + (Time.timetopretty(time),), 3) + return None times_in_secs.sort() inc_pretty_time = "\n".join(map(Time.timetopretty, times_in_secs)) @@ -775,17 +782,16 @@ def RemoveOlderThan(rootrp): Log.FatalError("Found %d relevant increments, dated:\n%s" "\nIf you want to delete multiple increments in this way, " "use the --force." % (len(times_in_secs), inc_pretty_time)) - if len(times_in_secs) == 1: Log("Deleting increment at time:\n" + inc_pretty_time, 3) else: Log("Deleting increments at times:\n" + inc_pretty_time, 3) - manage.delete_earlier_than(Globals.rbdir, time) + return times_in_secs[-1]+1 # make sure we don't delete current increment def rot_require_rbdir_base(rootrp): """Make sure pointing to base of rdiff-backup dir""" if restore_index != (): - Log.FatalError("Increments for directory %s cannot be removed separately.\n" - "Instead run on entire directory %s." % + Log.FatalError("Increments for directory %s cannot be removed " + "separately.\nInstead run on entire directory %s." % (rootrp.path, restore_root.path)) |