From 9ca80a54d894d093d6daad1d6de4c17d32b69511 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Wed, 21 Nov 2018 22:03:39 -0800 Subject: [PATCH] Support for Borg create --progress via borgmatic command-line flag (#108). --- NEWS | 3 +++ borgmatic/borg/create.py | 2 ++ borgmatic/commands/borgmatic.py | 11 +++++++++++ scripts/find-unsupported-borg-options | 1 + setup.py | 2 +- 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 138d08a..f8d1ab5 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +1.2.11 + * #108: Support for Borg create --progress via borgmatic command-line flag. + 1.2.10 * #105: Support for Borg --chunker-params create option via "chunker_params" in borgmatic's storage section. diff --git a/borgmatic/borg/create.py b/borgmatic/borg/create.py index cad0a29..eaf2e6e 100644 --- a/borgmatic/borg/create.py +++ b/borgmatic/borg/create.py @@ -104,6 +104,7 @@ def create_archive( storage_config, local_path='borg', remote_path=None, + progress=False, json=False, ): ''' @@ -151,6 +152,7 @@ def create_archive( + (('--stats',) if not dry_run and logger.isEnabledFor(logging.INFO) else ()) + (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ()) + (('--dry-run',) if dry_run else ()) + + (('--progress',) if progress else ()) + (('--json',) if json else ()) ) diff --git a/borgmatic/commands/borgmatic.py b/borgmatic/commands/borgmatic.py index 61629fb..d49c029 100644 --- a/borgmatic/commands/borgmatic.py +++ b/borgmatic/commands/borgmatic.py @@ -78,6 +78,13 @@ def parse_arguments(*arguments): action='store_true', help='Display summary information on archives', ) + parser.add_argument( + '--progress', + dest='progress', + default=False, + action='store_true', + help='Display progress with --create option for each file as it is backed up', + ) parser.add_argument( '--json', dest='json', @@ -103,6 +110,9 @@ def parse_arguments(*arguments): args = parser.parse_args(arguments) + if args.progress and not args.create: + raise ValueError('The --progress option can only be used with the --create option') + if args.json and not (args.create or args.list or args.info): raise ValueError( 'The --json option can only be used with the --create, --list, or --info options' @@ -212,6 +222,7 @@ def _run_commands_on_repository( storage, local_path=local_path, remote_path=remote_path, + progress=args.progress, ) if args.check and checks.repository_enabled_for_checks(repository, consistency): logger.info('{}: Running consistency checks'.format(repository)) diff --git a/scripts/find-unsupported-borg-options b/scripts/find-unsupported-borg-options index bd5f2db..8b98142 100755 --- a/scripts/find-unsupported-borg-options +++ b/scripts/find-unsupported-borg-options @@ -40,6 +40,7 @@ for sub_command in prune create check list info; do | grep -v '^--list$' \ | grep -v '^--nobsdflags$' \ | grep -v '^--pattern$' \ + | grep -v '^--progress$' \ | grep -v '^--read-special$' \ | grep -v '^--repository-only$' \ | grep -v '^--show-rc$' \ diff --git a/setup.py b/setup.py index cfff3d5..1ce7794 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ from setuptools import setup, find_packages -VERSION = '1.2.10' +VERSION = '1.2.11' setup(