From a350ab200eef0503d02e0e3db5948fcf4657c5a1 Mon Sep 17 00:00:00 2001 From: Michael Pimmer Date: Wed, 10 Oct 2018 10:31:14 +0000 Subject: [PATCH] Backups: Dont fail when borg doesn't find files to extract Reviewed-by: James Valleroy --- actions/backups | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/actions/backups b/actions/backups index 94f0f13cc..3b4159f2e 100755 --- a/actions/backups +++ b/actions/backups @@ -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)