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

This commit is contained in:
Divyansh Singh 2023-05-15 23:04:42 +05:30
parent e66e449c3b
commit 1bc7bb4971
2 changed files with 7 additions and 5 deletions

View File

@ -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(

View File

@ -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: