Permalink
Browse files

tklbam-restore: --force forces --raw-download to work with non-empty …

…directories
  • Loading branch information...
lirazsiri committed Nov 7, 2013
1 parent 95147c3 commit 50ad6f8929c3cef67d942f8b05ab2296f1187ae5
Showing with 11 additions and 6 deletions.
  1. +5 −4 cmd_restore.py
  2. +6 −2 duplicity.py
View
@@ -324,9 +324,6 @@ def main():
if not isdir(raw_download_path):
fatal("%s=%s is not a directory" % (opt, val))
- if os.listdir(raw_download_path) != []:
- fatal("%s=%s is not an empty directory" % (opt, val))
-
else:
os.mkdir(raw_download_path)
@@ -384,6 +381,10 @@ def main():
os.environ['TKLBAM_RESTORE_SKIP_' + skip_opt.upper()] = 'yes'
+ if raw_download_path:
+ if not opt_force and os.listdir(raw_download_path) != []:
+ fatal("--raw-download=%s is not an empty directory, use --force if that is ok" % raw_download_path)
+
restore_cache_size = conf.restore_cache_size
restore_cache_dir = conf.restore_cache_dir
@@ -451,7 +452,7 @@ def _print(s):
def get_backup_extract():
print fmt_title("Executing Duplicity to download %s to %s " % (address, raw_download_path))
- downloader(raw_download_path, target, log=_print if not silent else None, debug=opt_debug)
+ downloader(raw_download_path, target, log=_print if not silent else None, debug=opt_debug, force=opt_force)
return raw_download_path
if raw_download_path:
View
@@ -137,7 +137,7 @@ def __init__(self, time=None, cache_size=CACHE_SIZE, cache_dir=CACHE_DIR):
self.cache_size = cache_size
self.cache_dir = cache_dir
- def __call__(self, download_path, target, debug=False, log=None):
+ def __call__(self, download_path, target, debug=False, log=None, force=False):
if log is None:
log = lambda s: None
@@ -155,7 +155,11 @@ def __call__(self, download_path, target, debug=False, log=None):
os.environ['http_proxy'] = squid.address
_raise_rlimit(resource.RLIMIT_NOFILE, RLIMIT_NOFILE_MAX)
- command = Duplicity(opts, '--s3-unencrypted-connection', target.address, download_path)
+ args = [ '--s3-unencrypted-connection', target.address, download_path ]
+ if force:
+ args = [ '--force' ] + args
+
+ command = Duplicity(opts, *args)
log("# " + str(command))

0 comments on commit 50ad6f8

Please sign in to comment.