From fa3b1405902940e20f22e7e8a796a2b6428aee11 Mon Sep 17 00:00:00 2001 From: Vandal <86826719+VandalByte@users.noreply.github.com> Date: Mon, 24 Mar 2025 12:09:08 +0530 Subject: [PATCH] add patterns --- borgmatic/actions/recreate.py | 8 ++++++++ borgmatic/borg/recreate.py | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/borgmatic/actions/recreate.py b/borgmatic/actions/recreate.py index acac0d44..0f3a0d79 100644 --- a/borgmatic/actions/recreate.py +++ b/borgmatic/actions/recreate.py @@ -2,6 +2,7 @@ import logging import borgmatic.borg.recreate import borgmatic.config.validate +from borgmatic.actions.create import collect_patterns, process_patterns logger = logging.getLogger(__name__) @@ -26,6 +27,12 @@ def run_recreate( else: logger.info('Recreating repository') + # collect and process patterns + patterns = collect_patterns(config) + processed_patterns = process_patterns( + patterns, borgmatic.config.paths.get_working_directory(config) + ) + borgmatic.borg.recreate.recreate_archive( repository['path'], borgmatic.borg.repo_list.resolve_archive_name( @@ -43,4 +50,5 @@ def run_recreate( global_arguments, local_path=local_path, remote_path=remote_path, + patterns=processed_patterns, ) diff --git a/borgmatic/borg/recreate.py b/borgmatic/borg/recreate.py index fd547e2f..9cc54679 100644 --- a/borgmatic/borg/recreate.py +++ b/borgmatic/borg/recreate.py @@ -18,6 +18,7 @@ def recreate_archive( global_arguments, local_path, remote_path=None, + patterns=None, ): ''' Given a local or remote repository path, an archive name, a configuration dict, @@ -32,7 +33,7 @@ def recreate_archive( exclude_flags = make_exclude_flags(config) # handle path from recreate_arguments path_flag = ('--path', recreate_arguments.path) if recreate_arguments.path else () - + pattern_flags = ('--patterns-from', patterns) if patterns else () recreate_cmd = ( (local_path, 'recreate') @@ -43,6 +44,7 @@ def recreate_archive( + (('--lock-wait', str(lock_wait)) if lock_wait else ()) + (('--info',) if logger.getEffectiveLevel() == logging.INFO else ()) + (('--debug', '--show-rc', '--list') if logger.isEnabledFor(logging.DEBUG) else ()) + + pattern_flags + exclude_flags )