From 9e216f6742402902e468d5a44ae4fd9a03ce94cf Mon Sep 17 00:00:00 2001 From: owsla Date: Mon, 9 Mar 2009 14:27:18 +0000 Subject: Suppress traceback if permission error during restore git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/branches/r1-2@1043 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109 --- rdiff-backup/CHANGELOG | 3 +++ rdiff-backup/rdiff_backup/Main.py | 33 ++++++++++++++++++++++++--------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/rdiff-backup/CHANGELOG b/rdiff-backup/CHANGELOG index a4436df..b75d136 100644 --- a/rdiff-backup/CHANGELOG +++ b/rdiff-backup/CHANGELOG @@ -1,6 +1,9 @@ New in v1.2.8 (????/??/??) --------------------------- +Improve handling of incorrect permissions on backup repository during restore +operation. Closes Ubuntu bug #329722. (Andrew Ferguson) + Don't crash on zlib errors. Closes Debian bug #518531. (Andrew Ferguson) Make sticky bit warnings quieter while determining file system abilities. diff --git a/rdiff-backup/rdiff_backup/Main.py b/rdiff-backup/rdiff_backup/Main.py index f9033e7..bba2afa 100644 --- a/rdiff-backup/rdiff_backup/Main.py +++ b/rdiff-backup/rdiff_backup/Main.py @@ -20,7 +20,7 @@ """Start (and end) here - read arguments, set global settings, etc.""" from __future__ import generators -import getopt, sys, re, os, cStringIO, tempfile +import getopt, sys, re, os, cStringIO, tempfile, errno from log import Log, LoggerError, ErrorLog import Globals, Time, SetConnections, selection, robust, rpath, \ manage, backup, connection, restore, FilenameMapping, \ @@ -426,8 +426,12 @@ def backup_set_rbdir(rpin, rpout): global incdir try: incdir = Globals.rbdir.append_path("increments") - except (OSError, IOError), exc: - Log.FatalError("Could not begin backup due to\n%s" % exc) + except IOError, exc: + if exc.errno == errno.EACCES: + print "\n" + Log.FatalError("Could not begin backup due to\n%s" % exc) + else: + raise assert rpout.lstat(), (rpout.path, rpout.lstat()) if rpout.isdir() and not rpout.listdir(): # rpout is empty dir @@ -548,9 +552,12 @@ def Restore(src_rp, dest_rp, restore_as_of = None): restore_check_paths(src_rp, dest_rp, restore_as_of) try: dest_rp.conn.fs_abilities.restore_set_globals(dest_rp) - except (OSError, IOError), exc: - print "\n" - Log.FatalError("Could not begin restore due to\n%s" % exc) + except IOError, exc: + if exc.errno == errno.EACCES: + print "\n" + Log.FatalError("Could not begin restore due to\n%s" % exc) + else: + raise init_user_group_mapping(dest_rp.conn) src_rp = restore_init_quoting(src_rp) restore_check_backup_dir(restore_root, src_rp, restore_as_of) @@ -561,9 +568,17 @@ def Restore(src_rp, dest_rp, restore_as_of = None): else: time = src_rp.getinctime() restore_set_select(restore_root, dest_rp) restore_start_log(src_rp, dest_rp, time) - restore.Restore(restore_root.new_index(restore_index), - inc_rpath, dest_rp, time) - Log("Restore finished", 4) + try: + restore.Restore(restore_root.new_index(restore_index), + inc_rpath, dest_rp, time) + except IOError, exc: + if exc.errno == errno.EACCES: + print "\n" + Log.FatalError("Could not complete restore due to\n%s" % exc) + else: + raise + else: + Log("Restore finished", 4) def restore_init_quoting(src_rp): """Change rpaths into quoted versions of themselves if necessary""" -- cgit v1.2.1