瀏覽代碼

add patterns

Vandal 2 月之前
父節點
當前提交
fa3b140590
共有 2 個文件被更改,包括 11 次插入1 次删除
  1. 8 0
      borgmatic/actions/recreate.py
  2. 3 1
      borgmatic/borg/recreate.py

+ 8 - 0
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,
         )

+ 3 - 1
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
     )