summaryrefslogtreecommitdiff
path: root/ryrestore.py
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2010-05-30 23:34:23 +0200
committerAdrian C. (anrxc) <anrxc@sysphere.org>2010-05-30 23:34:47 +0200
commit6f63f9fae8af223bc82b696e989fd1b9b7985161 (patch)
tree69fa92c4edc73e7185d3dcb701350ed641e77145 /ryrestore.py
parent0376026de09733315a9ffddc98b2f6d97919f52b (diff)
downloadrybackup-6f63f9fae8af223bc82b696e989fd1b9b7985161.tar.xz
ryrestore: improved error handling
Diffstat (limited to 'ryrestore.py')
-rwxr-xr-xryrestore.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/ryrestore.py b/ryrestore.py
index 1404a38..9577a39 100755
--- a/ryrestore.py
+++ b/ryrestore.py
@@ -25,10 +25,7 @@ from rybackup import bak, bin, mount
#
# Managing backup snapshots
def select(source):
- try:
- snapshots = listdir(source)
- except OSError:
- raise SystemExit("Error: unable to read backup source")
+ snapshots = listdir(source)
# Present the selection to the user, with numbered IDs
for index, directory in enumerate(snapshots):
@@ -43,13 +40,16 @@ def select(source):
def restore(source, destination):
try:
bsnap = select(source)
- except (ValueError, IndexError):
- raise SystemExit("Error: incorrect snapshot ID")
-
- # Mirroring options
- rsyncopt = (
+ except KeyboardInterrupt:
+ print "\nError: user initiated exit"
+ return
+ except Exception, error:
+ print "Error: incorrect snapshot ID or backup source\nDebug:", error
+ return
+
+ rsyncopt = ( # Mirroring options
"--archive", # use the archive mode,
- "--verbose", # increase verbosity,
+ "--verbose", # increase verbosity
)
# Restore from backup with rsync
@@ -65,9 +65,10 @@ def main():
if getuid() != 0:
raise SystemExit("Error: super user privileges required")
try:
- mount("mount")
- restore(bak['dst'], argv[1])
- mount("umount")
+ if argv[1] != None:
+ mount("mount")
+ restore(bak['dst'], argv[1])
+ mount("umount")
except IndexError:
raise SystemExit(usage)