summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)