From f91bfd2eb7449a0dced6bf1f356db57904dd65d5 Mon Sep 17 00:00:00 2001 From: Michael Vrable Date: Wed, 27 Feb 2008 16:20:31 -0800 Subject: [PATCH] Allow restores of just selected files/directories. Previously, only a complete snapshot could be restored. This change to lbs-util will allow just selected data to be restored. --- lbs-util | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lbs-util b/lbs-util index da89060..6f97129 100755 --- a/lbs-util +++ b/lbs-util @@ -178,6 +178,17 @@ def cmd_restore_snapshot(args): destdir = args[1] paths = args[2:] + def matchpath(path): + "Return true if the specified path should be included in the restore." + + # No specification of what to restore => restore everything + if len(paths) == 0: return True + + for p in paths: + if path == p: return True + if path.startswith(p + "/"): return True + return False + def warn(m, msg): print "Warning: %s: %s" % (m.items.name, msg) @@ -185,6 +196,7 @@ def cmd_restore_snapshot(args): pathname = os.path.normpath(m.items.name) while os.path.isabs(pathname): pathname = pathname[1:] + if not matchpath(pathname): continue print pathname destpath = os.path.join(destdir, pathname) (path, filename) = os.path.split(destpath) -- 2.20.1