diff --git a/borgmatic/borg/create.py b/borgmatic/borg/create.py index fb2fff93..843789ab 100644 --- a/borgmatic/borg/create.py +++ b/borgmatic/borg/create.py @@ -157,4 +157,5 @@ def create_archive( ) logger.debug(' '.join(full_command)) - subprocess.check_call(full_command) + output = subprocess.check_output(full_command) + return output.decode() if output is not None else None diff --git a/borgmatic/commands/borgmatic.py b/borgmatic/commands/borgmatic.py index 5ed6cb10..b44c37ce 100644 --- a/borgmatic/commands/borgmatic.py +++ b/borgmatic/commands/borgmatic.py @@ -155,7 +155,7 @@ def _run_commands(args, consistency, local_path, location, remote_path, retentio unexpanded_repository, ) if args.json: - sys.stdout.write(json.dumps(json_results)) + sys.stdout.write(json.dumps(json_results, indent=2)) def _run_commands_on_repository( @@ -176,14 +176,19 @@ def _run_commands_on_repository( ) if args.create: logger.info('{}: Creating archive{}'.format(repository, dry_run_label)) - borg_create.create_archive( + output = borg_create.create_archive( args.dry_run, repository, location, storage, local_path=local_path, remote_path=remote_path, + json=args.json, ) + if args.json: + json_results.append(json.loads(output)) + else: + sys.stdout.write(output) if args.check: logger.info('{}: Running consistency checks'.format(repository)) borg_check.check_archives(