summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-10-27 13:34:18 +0000
committerLars Wirzenius <liw@liw.fi>2013-10-27 13:34:18 +0000
commit446bf342f995d8f5de1dd7a5f627ac4c72487209 (patch)
tree648577cfd6ce8bbcddc8d5aae53ac4dfea701ced
parent554570702c2077e3e8e7e6626374d1409f78d718 (diff)
downloadobnam-446bf342f995d8f5de1dd7a5f627ac4c72487209.tar.gz
Make restore not abort at first error
-rw-r--r--NEWS4
-rw-r--r--obnamlib/plugins/restore_plugin.py10
-rw-r--r--tests/fail-on-mangled-chunk.stderr2
3 files changed, 15 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 0aa545b6..a45b6a11 100644
--- a/NEWS
+++ b/NEWS
@@ -66,6 +66,10 @@ Bug fixes:
* `obnam ls` now handles trailing slashes in filename arguments.
Reported by Biltong.
+* When restoring a backup, Obnam will now continue past errors,
+ instead of aborting with the first one. Patch by Itamar
+ Turner-Trauring.
+
Version 1.5, released 2013-08-08
--------------------------------
diff --git a/obnamlib/plugins/restore_plugin.py b/obnamlib/plugins/restore_plugin.py
index ed732e55..cb8afab4 100644
--- a/obnamlib/plugins/restore_plugin.py
+++ b/obnamlib/plugins/restore_plugin.py
@@ -151,6 +151,10 @@ class RestorePlugin(obnamlib.ObnamPlugin):
for pathname, metadata in self.repo.walk(gen, root, depth_first=True):
self.file_count += 1
self.app.ts['current'] = pathname
+ self.restore_safely(gen, pathname, metadata)
+
+ def restore_safely(self, gen, pathname, metadata):
+ try:
dirname = os.path.dirname(pathname)
if self.write_ok and not self.fs.exists('./' + dirname):
self.fs.makedirs('./' + dirname)
@@ -179,6 +183,12 @@ class RestorePlugin(obnamlib.ObnamPlugin):
logging.error(msg)
self.app.ts.notify(msg)
self.errors = True
+ except Exception, e:
+ # Reaching this code path means we've hit a bug, so we log a full traceback.
+ msg = "Failed to restore %s:" % (pathname,)
+ logging.exception(msg)
+ self.app.ts.notify(msg + " " + str(e))
+ self.errors = True
def restore_dir(self, gen, root, metadata):
logging.debug('restoring dir %s' % root)
diff --git a/tests/fail-on-mangled-chunk.stderr b/tests/fail-on-mangled-chunk.stderr
index cee0d26b..4def1409 100644
--- a/tests/fail-on-mangled-chunk.stderr
+++ b/tests/fail-on-mangled-chunk.stderr
@@ -1 +1 @@
-ERROR: chunk BLOTTED checksum error
+ERROR: There were errors when restoring