Backups: Dont fail when borg doesn't find files to extract

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Michael Pimmer 2018-10-10 10:31:14 +00:00 committed by James Valleroy
parent c770a7adfb
commit a350ab200e
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -149,7 +149,17 @@ def _extract(archive_path, destination, locations=None):
print(borg_call)
try:
os.chdir(os.path.expanduser(destination))
subprocess.run(borg_call, env=env, check=True)
# TODO: with python 3.7 use subprocess.run with the 'capture_output'
# argument
process = subprocess.run(borg_call, env=env,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
if process.returncode != 0:
error = process.stderr.decode()
# Don't fail on the borg error when no files were matched
if "never matched" not in error:
raise subprocess.CalledProcessError(process.returncode,
process.args)
finally:
os.chdir(prev_dir)