summaryrefslogtreecommitdiff
path: root/rdiff-backup
diff options
context:
space:
mode:
Diffstat (limited to 'rdiff-backup')
-rw-r--r--rdiff-backup/rdiff_backup/increment.py11
-rw-r--r--rdiff-backup/rdiff_backup/restore.py7
-rw-r--r--rdiff-backup/rdiff_backup/rpath.py1
-rw-r--r--rdiff-backup/src/increment.py11
-rwxr-xr-xrdiff-backup/src/main.py4
-rw-r--r--rdiff-backup/src/restore.py7
-rw-r--r--rdiff-backup/src/rpath.py1
7 files changed, 18 insertions, 24 deletions
diff --git a/rdiff-backup/rdiff_backup/increment.py b/rdiff-backup/rdiff_backup/increment.py
index 5836f63..b03b464 100644
--- a/rdiff-backup/rdiff_backup/increment.py
+++ b/rdiff-backup/rdiff_backup/increment.py
@@ -10,12 +10,6 @@ execfile("statistics.py")
class Inc:
"""Class containing increment functions"""
- # This is a hack. _inc_file holds the dsrp of the latest
- # increment file created, to be used in IncrementITR for
- # statistics purposes. It should be given directly to the ITR
- # object but there didn't seem to be a good way to pass it out.
- _inc_file = None
-
def Increment_action(new, mirror, incpref):
"""Main file incrementing function, returns RobustAction
@@ -116,7 +110,6 @@ class Inc:
inctime = Resume.FindTime(rp.index, inctime)
incrp = Inc.get_inc(rp, inctime, typestr)
if not incrp.lstat(): break
- Inc._inc_file = incrp
return incrp
MakeStatic(Inc)
@@ -236,6 +229,7 @@ class IncrementITR(ErrorITR, StatsITR):
else: # restore to previous state
if old_dsrp_tf.lstat(): old_dsrp_tf.rename(dsrp)
if self.incrp: self.incrp.delete()
+ mirror_tf.delete()
RobustAction(init_thunk, final, error).execute()
else: self.incrp = Robust.chain(
@@ -247,7 +241,8 @@ class IncrementITR(ErrorITR, StatsITR):
def end_process(self):
"""Do final work when leaving a tree (directory)"""
diff_rorp, dsrp, incpref = self.diff_rorp, self.dsrp, self.incpref
- if self.mirror_isdirectory and (diff_rorp or self.changed):
+ if (self.mirror_isdirectory and (diff_rorp or self.changed)
+ or self.directory_replacement):
if self.directory_replacement:
tf = self.directory_replacement
self.incrp = Robust.chain(
diff --git a/rdiff-backup/rdiff_backup/restore.py b/rdiff-backup/rdiff_backup/restore.py
index 5026716..30820b8 100644
--- a/rdiff-backup/rdiff_backup/restore.py
+++ b/rdiff-backup/rdiff_backup/restore.py
@@ -28,7 +28,7 @@ class Restore:
if not isinstance(target, DSRPath): target = DSRPath(None, target)
mirror_time = Restore.get_mirror_time()
- rest_time = Restore.get_rest_time(rest_time)
+ rest_time = Restore.get_rest_time(rest_time, mirror_time)
inc_list = Restore.get_inclist(inc_rpath)
rid = RestoreIncrementData(inc_rpath.index, inc_rpath, inc_list)
rid.sortincseq(rest_time, mirror_time)
@@ -46,7 +46,7 @@ class Restore:
Log("Warning, two different dates for current mirror found", 2)
return Time.stringtotime(current_mirror_incs[0].getinctime())
- def get_rest_time(old_rest_time):
+ def get_rest_time(old_rest_time, mirror_time):
"""If old_rest_time is between two increments, return older time
There is a slightly tricky reason for doing this: The rest of
@@ -64,7 +64,8 @@ class Restore:
base_incs = Restore.get_inclist(Globals.rbdir.append("increments"))
if not base_incs: return old_rest_time
inctimes = [Time.stringtotime(inc.getinctime()) for inc in base_incs]
- return max(filter(lambda time: time <= old_rest_time, inctimes))
+ return max(filter(lambda time: time <= old_rest_time,
+ inctimes + [mirror_time]))
def get_inclist(inc_rpath):
"""Returns increments with given base"""
diff --git a/rdiff-backup/rdiff_backup/rpath.py b/rdiff-backup/rdiff_backup/rpath.py
index c17bf95..c9ea312 100644
--- a/rdiff-backup/rdiff_backup/rpath.py
+++ b/rdiff-backup/rdiff_backup/rpath.py
@@ -445,6 +445,7 @@ class RPath(RORPath):
"""Reproduce RPath from __getstate__ output"""
self.conn = Globals.local_connection
self.index, self.base, self.data = rpath_state
+ self.path = apply(os.path.join, (self.base,) + self.index)
def setdata(self):
"""Create the data dictionary"""
diff --git a/rdiff-backup/src/increment.py b/rdiff-backup/src/increment.py
index 5836f63..b03b464 100644
--- a/rdiff-backup/src/increment.py
+++ b/rdiff-backup/src/increment.py
@@ -10,12 +10,6 @@ execfile("statistics.py")
class Inc:
"""Class containing increment functions"""
- # This is a hack. _inc_file holds the dsrp of the latest
- # increment file created, to be used in IncrementITR for
- # statistics purposes. It should be given directly to the ITR
- # object but there didn't seem to be a good way to pass it out.
- _inc_file = None
-
def Increment_action(new, mirror, incpref):
"""Main file incrementing function, returns RobustAction
@@ -116,7 +110,6 @@ class Inc:
inctime = Resume.FindTime(rp.index, inctime)
incrp = Inc.get_inc(rp, inctime, typestr)
if not incrp.lstat(): break
- Inc._inc_file = incrp
return incrp
MakeStatic(Inc)
@@ -236,6 +229,7 @@ class IncrementITR(ErrorITR, StatsITR):
else: # restore to previous state
if old_dsrp_tf.lstat(): old_dsrp_tf.rename(dsrp)
if self.incrp: self.incrp.delete()
+ mirror_tf.delete()
RobustAction(init_thunk, final, error).execute()
else: self.incrp = Robust.chain(
@@ -247,7 +241,8 @@ class IncrementITR(ErrorITR, StatsITR):
def end_process(self):
"""Do final work when leaving a tree (directory)"""
diff_rorp, dsrp, incpref = self.diff_rorp, self.dsrp, self.incpref
- if self.mirror_isdirectory and (diff_rorp or self.changed):
+ if (self.mirror_isdirectory and (diff_rorp or self.changed)
+ or self.directory_replacement):
if self.directory_replacement:
tf = self.directory_replacement
self.incrp = Robust.chain(
diff --git a/rdiff-backup/src/main.py b/rdiff-backup/src/main.py
index f050435..e8a15af 100755
--- a/rdiff-backup/src/main.py
+++ b/rdiff-backup/src/main.py
@@ -356,7 +356,7 @@ went wrong during your last backup? Using """ + mirrorrps[-1].path, 2)
"""
self.restore_check_paths(rpin, target, 1)
try: time = Time.genstrtotime(self.restore_timestr)
- except TimeError, exc: Log.FatalError(str(exc))
+ except TimeException, exc: Log.FatalError(str(exc))
self.restore_common(rpin, target, time)
def restore_common(self, rpin, target, time):
@@ -383,7 +383,7 @@ Try restoring from an increment file (the filenames look like
if not rpout: rpout = RPath(Globals.local_connection,
rpin.getincbase_str())
if rpout.lstat():
- Log.FatalError("Restore target %s already exists,"
+ Log.FatalError("Restore target %s already exists, "
"and will not be overwritten." % rpout.path)
return rpin, rpout
diff --git a/rdiff-backup/src/restore.py b/rdiff-backup/src/restore.py
index 5026716..30820b8 100644
--- a/rdiff-backup/src/restore.py
+++ b/rdiff-backup/src/restore.py
@@ -28,7 +28,7 @@ class Restore:
if not isinstance(target, DSRPath): target = DSRPath(None, target)
mirror_time = Restore.get_mirror_time()
- rest_time = Restore.get_rest_time(rest_time)
+ rest_time = Restore.get_rest_time(rest_time, mirror_time)
inc_list = Restore.get_inclist(inc_rpath)
rid = RestoreIncrementData(inc_rpath.index, inc_rpath, inc_list)
rid.sortincseq(rest_time, mirror_time)
@@ -46,7 +46,7 @@ class Restore:
Log("Warning, two different dates for current mirror found", 2)
return Time.stringtotime(current_mirror_incs[0].getinctime())
- def get_rest_time(old_rest_time):
+ def get_rest_time(old_rest_time, mirror_time):
"""If old_rest_time is between two increments, return older time
There is a slightly tricky reason for doing this: The rest of
@@ -64,7 +64,8 @@ class Restore:
base_incs = Restore.get_inclist(Globals.rbdir.append("increments"))
if not base_incs: return old_rest_time
inctimes = [Time.stringtotime(inc.getinctime()) for inc in base_incs]
- return max(filter(lambda time: time <= old_rest_time, inctimes))
+ return max(filter(lambda time: time <= old_rest_time,
+ inctimes + [mirror_time]))
def get_inclist(inc_rpath):
"""Returns increments with given base"""
diff --git a/rdiff-backup/src/rpath.py b/rdiff-backup/src/rpath.py
index c17bf95..c9ea312 100644
--- a/rdiff-backup/src/rpath.py
+++ b/rdiff-backup/src/rpath.py
@@ -445,6 +445,7 @@ class RPath(RORPath):
"""Reproduce RPath from __getstate__ output"""
self.conn = Globals.local_connection
self.index, self.base, self.data = rpath_state
+ self.path = apply(os.path.join, (self.base,) + self.index)
def setdata(self):
"""Create the data dictionary"""