diff options
Diffstat (limited to 'rdiff-backup')
-rw-r--r-- | rdiff-backup/CHANGELOG | 4 | ||||
-rw-r--r-- | rdiff-backup/TODO | 7 | ||||
-rw-r--r-- | rdiff-backup/rdiff_backup/Globals.py | 6 | ||||
-rw-r--r-- | rdiff-backup/rdiff_backup/Main.py | 20 | ||||
-rw-r--r-- | rdiff-backup/testing/finaltest.py | 27 |
5 files changed, 44 insertions, 20 deletions
diff --git a/rdiff-backup/CHANGELOG b/rdiff-backup/CHANGELOG index 3cb199e..1de8500 100644 --- a/rdiff-backup/CHANGELOG +++ b/rdiff-backup/CHANGELOG @@ -16,6 +16,10 @@ Due to very detailed error report from Yoav, fixed a "Directory not empty" error that can arise on emulated filesystems like NFS and EncFS. +Cleaned up remove older than report, and also stopped it from deleting +current data files if you specify a time later than the current +mirror. + New in v1.1.2 (2005/11/06) -------------------------- diff --git a/rdiff-backup/TODO b/rdiff-backup/TODO index 364bda6..d3b1a21 100644 --- a/rdiff-backup/TODO +++ b/rdiff-backup/TODO @@ -1,10 +1,3 @@ -Make sure remove older than doesn't delete current snapshot. When no -increments found, don't act like there's an error (no stderr). - -Port close file fix to devel version - -See if rorpiter.CacheIndexable is really necessary - For comparing, check source filesystem's abilities Clean up compare reports diff --git a/rdiff-backup/rdiff_backup/Globals.py b/rdiff-backup/rdiff_backup/Globals.py index 253c8a7..952208c 100644 --- a/rdiff-backup/rdiff_backup/Globals.py +++ b/rdiff-backup/rdiff_backup/Globals.py @@ -37,9 +37,9 @@ blocksize = 131072 # values may save on connection overhead and latency. conn_bufsize = 393216 -# This is used in rorpiter.CacheIndexable. The number represents the -# number of rpaths which may be stuck in buffers when moving over a -# remote connection. +# This is used in the CacheCollatedPostProcess and MiscIterToFile +# classes. The number represents the number of rpaths which may be +# stuck in buffers when moving over a remote connection. pipeline_max_length = 500 # True if script is running as a server diff --git a/rdiff-backup/rdiff_backup/Main.py b/rdiff-backup/rdiff_backup/Main.py index 54ae90a..997018c 100644 --- a/rdiff-backup/rdiff_backup/Main.py +++ b/rdiff-backup/rdiff_backup/Main.py @@ -658,17 +658,24 @@ def RemoveOlderThan(rootrp): """Remove all increment files older than a certain time""" rootrp = require_root_set(rootrp, 0) 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)) @@ -676,11 +683,10 @@ 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""" diff --git a/rdiff-backup/testing/finaltest.py b/rdiff-backup/testing/finaltest.py index 8fe04f1..6dc73f2 100644 --- a/rdiff-backup/testing/finaltest.py +++ b/rdiff-backup/testing/finaltest.py @@ -427,13 +427,34 @@ class FinalMisc(PathSetter): for inc in self.get_all_increments(rbdir): assert inc.getinctime() >= 30000 + def testRemoveOlderThanCurrent(self): + """Make sure --remove-older-than doesn't delete current incs""" + Myrm("testfiles/output") + assert not os.system('cp -a testfiles/restoretest3 testfiles/output') + self.set_connections(None, None, None, None) + self.exec_rb_extra_args(None, '--remove-older-than now --force', + 'testfiles/output') + rbdir = rpath.RPath(Globals.local_connection, + "testfiles/output/rdiff-backup-data") + + has_cur_mirror, has_metadata = 0, 0 + for inc in self.get_all_increments(rbdir): + if inc.getincbase().index[-1] == 'current_mirror': + has_cur_mirror = 1 + elif inc.getincbase().index[-1] == 'mirror_metadata': + has_metadata = 1 + assert has_cur_mirror and has_metadata, (has_cur_mirror, has_metadata) + def testRemoveOlderThanQuoting(self): """Test --remove-older-than when dest directory is quoted""" Myrm("testfiles/output") self.set_connections(None, None, None, None) - self.exec_rb_extra_args(None, "--override-chars-to-quote '^a-z0-9_ -.'", - "testfiles/increment1", "testfiles/output") - self.exec_rb_extra_args(None, "--remove-older-than now", "testfiles/output") + self.exec_rb_extra_args(None, "--override-chars-to-quote '^a-z0-9_ -.'" + " --current-time 10000", "testfiles/increment1", "testfiles/output") + self.exec_rb_extra_args(None, "--override-chars-to-quote '^a-z0-9_ -.'" + " --current-time 20000", "testfiles/increment2", "testfiles/output") + self.exec_rb_extra_args(None, "--remove-older-than now", + "testfiles/output") def testRemoveOlderThanRemote(self): """Test --remove-older-than remotely""" |