2
0
Эх сурвалжийг харах

feat: store configs used to create an archive in the archive

Divyansh Singh 2 жил өмнө
parent
commit
1bc7bb4971

+ 1 - 1
borgmatic/borg/create.py

@@ -351,7 +351,7 @@ def create_archive(
     sources = deduplicate_directories(
         map_directories_to_devices(
             expand_directories(
-                tuple(location_config.get('source_directories', ())) + borgmatic_source_directories
+                tuple(location_config.get('source_directories', ())) + borgmatic_source_directories + tuple(global_arguments.config_paths)
             )
         ),
         additional_directory_devices=map_directories_to_devices(

+ 6 - 4
borgmatic/commands/borgmatic.py

@@ -45,10 +45,10 @@ logger = logging.getLogger(__name__)
 LEGACY_CONFIG_PATH = '/etc/borgmatic/config'
 
 
-def run_configuration(config_filename, config, arguments):
+def run_configuration(config_filename, config, arguments, used_config_paths):
     '''
-    Given a config filename, the corresponding parsed config dict, and command-line arguments as a
-    dict from subparser name to a namespace of parsed arguments, execute the defined create, prune,
+    Given a config filename, the corresponding parsed config dict, command-line arguments as a
+    dict from subparser name to a namespace of parsed arguments, and a list of paths of all configs used, execute the defined create, prune,
     compact, check, and/or other actions.
 
     Yield a combination of:
@@ -61,6 +61,7 @@ def run_configuration(config_filename, config, arguments):
         for section_name in ('location', 'storage', 'retention', 'consistency', 'hooks')
     )
     global_arguments = arguments['global']
+    global_arguments.config_paths = used_config_paths
 
     local_path = location.get('local_path', 'borg')
     remote_path = location.get('remote_path')
@@ -644,8 +645,9 @@ def collect_configuration_run_summary_logs(configs, arguments):
 
     # Execute the actions corresponding to each configuration file.
     json_results = []
+    used_config_paths = list(configs.keys())
     for config_filename, config in configs.items():
-        results = list(run_configuration(config_filename, config, arguments))
+        results = list(run_configuration(config_filename, config, arguments, used_config_paths))
         error_logs = tuple(result for result in results if isinstance(result, logging.LogRecord))
 
         if error_logs: