Partial conversion of showing repository labels in logs instead of paths (part of #635).
This commit is contained in:
parent
ba845d4008
commit
b45e45f161
16 changed files with 54 additions and 29 deletions
|
@ -22,7 +22,9 @@ def run_borg(
|
|||
if borg_arguments.repository is None or borgmatic.config.validate.repositories_match(
|
||||
repository, borg_arguments.repository
|
||||
):
|
||||
logger.info(f'{repository["path"]}: Running arbitrary Borg command')
|
||||
logger.info(
|
||||
f'{repository.get("label", repository["path"])}: Running arbitrary Borg command'
|
||||
)
|
||||
archive_name = borgmatic.borg.rlist.resolve_archive_name(
|
||||
repository['path'],
|
||||
borg_arguments.archive,
|
||||
|
|
|
@ -21,7 +21,9 @@ def run_break_lock(
|
|||
if break_lock_arguments.repository is None or borgmatic.config.validate.repositories_match(
|
||||
repository, break_lock_arguments.repository
|
||||
):
|
||||
logger.info(f'{repository["path"]}: Breaking repository and cache locks')
|
||||
logger.info(
|
||||
f'{repository.get("label", repository["path"])}: Breaking repository and cache locks'
|
||||
)
|
||||
borgmatic.borg.break_lock.break_lock(
|
||||
repository['path'],
|
||||
storage,
|
||||
|
|
|
@ -37,7 +37,7 @@ def run_check(
|
|||
global_arguments.dry_run,
|
||||
**hook_context,
|
||||
)
|
||||
logger.info(f'{repository["path"]}: Running consistency checks')
|
||||
logger.info(f'{repository.get("label", repository["path"])}: Running consistency checks')
|
||||
borgmatic.borg.check.check_archives(
|
||||
repository['path'],
|
||||
location,
|
||||
|
|
|
@ -39,7 +39,9 @@ def run_compact(
|
|||
**hook_context,
|
||||
)
|
||||
if borgmatic.borg.feature.available(borgmatic.borg.feature.Feature.COMPACT, local_borg_version):
|
||||
logger.info(f'{repository["path"]}: Compacting segments{dry_run_label}')
|
||||
logger.info(
|
||||
f'{repository.get("label", repository["path"])}: Compacting segments{dry_run_label}'
|
||||
)
|
||||
borgmatic.borg.compact.compact_segments(
|
||||
global_arguments.dry_run,
|
||||
repository['path'],
|
||||
|
@ -53,7 +55,9 @@ def run_compact(
|
|||
threshold=compact_arguments.threshold,
|
||||
)
|
||||
else: # pragma: nocover
|
||||
logger.info(f'{repository["path"]}: Skipping compact (only available/needed in Borg 1.2+)')
|
||||
logger.info(
|
||||
f'{repository.get("label", repository["path"])}: Skipping compact (only available/needed in Borg 1.2+)'
|
||||
)
|
||||
borgmatic.hooks.command.execute_hook(
|
||||
hooks.get('after_compact'),
|
||||
hooks.get('umask'),
|
||||
|
|
|
@ -42,7 +42,7 @@ def run_create(
|
|||
global_arguments.dry_run,
|
||||
**hook_context,
|
||||
)
|
||||
logger.info(f'{repository["path"]}: Creating archive{dry_run_label}')
|
||||
logger.info(f'{repository.get("label", repository["path"])}: Creating archive{dry_run_label}')
|
||||
borgmatic.hooks.dispatch.call_hooks_even_if_unconfigured(
|
||||
'remove_database_dumps',
|
||||
hooks,
|
||||
|
|
|
@ -35,7 +35,9 @@ def run_extract(
|
|||
if extract_arguments.repository is None or borgmatic.config.validate.repositories_match(
|
||||
repository, extract_arguments.repository
|
||||
):
|
||||
logger.info(f'{repository["path"]}: Extracting archive {extract_arguments.archive}')
|
||||
logger.info(
|
||||
f'{repository.get("label", repository["path"])}: Extracting archive {extract_arguments.archive}'
|
||||
)
|
||||
borgmatic.borg.extract.extract_archive(
|
||||
global_arguments.dry_run,
|
||||
repository['path'],
|
||||
|
|
|
@ -26,7 +26,9 @@ def run_info(
|
|||
repository, info_arguments.repository
|
||||
):
|
||||
if not info_arguments.json: # pragma: nocover
|
||||
logger.answer(f'{repository["path"]}: Displaying archive summary information')
|
||||
logger.answer(
|
||||
f'{repository.get("label", repository["path"])}: Displaying archive summary information'
|
||||
)
|
||||
info_arguments.archive = borgmatic.borg.rlist.resolve_archive_name(
|
||||
repository['path'],
|
||||
info_arguments.archive,
|
||||
|
|
|
@ -26,9 +26,9 @@ def run_list(
|
|||
):
|
||||
if not list_arguments.json: # pragma: nocover
|
||||
if list_arguments.find_paths:
|
||||
logger.answer(f'{repository["path"]}: Searching archives')
|
||||
logger.answer(f'{repository.get("label", repository["path"])}: Searching archives')
|
||||
elif not list_arguments.archive:
|
||||
logger.answer(f'{repository["path"]}: Listing archives')
|
||||
logger.answer(f'{repository.get("label", repository["path"])}: Listing archives')
|
||||
list_arguments.archive = borgmatic.borg.rlist.resolve_archive_name(
|
||||
repository['path'],
|
||||
list_arguments.archive,
|
||||
|
|
|
@ -23,9 +23,11 @@ def run_mount(
|
|||
repository, mount_arguments.repository
|
||||
):
|
||||
if mount_arguments.archive:
|
||||
logger.info(f'{repository["path"]}: Mounting archive {mount_arguments.archive}')
|
||||
logger.info(
|
||||
f'{repository.get("label", repository["path"])}: Mounting archive {mount_arguments.archive}'
|
||||
)
|
||||
else: # pragma: nocover
|
||||
logger.info(f'{repository["path"]}: Mounting repository')
|
||||
logger.info(f'{repository.get("label", repository["path"])}: Mounting repository')
|
||||
|
||||
borgmatic.borg.mount.mount_archive(
|
||||
repository['path'],
|
||||
|
|
|
@ -37,7 +37,7 @@ def run_prune(
|
|||
global_arguments.dry_run,
|
||||
**hook_context,
|
||||
)
|
||||
logger.info(f'{repository["path"]}: Pruning archives{dry_run_label}')
|
||||
logger.info(f'{repository.get("label", repository["path"])}: Pruning archives{dry_run_label}')
|
||||
borgmatic.borg.prune.prune_archives(
|
||||
global_arguments.dry_run,
|
||||
repository['path'],
|
||||
|
|
|
@ -23,7 +23,7 @@ def run_rcreate(
|
|||
):
|
||||
return
|
||||
|
||||
logger.info(f'{repository["path"]}: Creating repository')
|
||||
logger.info(f'{repository.get("label", repository["path"])}: Creating repository')
|
||||
borgmatic.borg.rcreate.create_repository(
|
||||
global_arguments.dry_run,
|
||||
repository['path'],
|
||||
|
|
|
@ -73,12 +73,14 @@ def restore_single_database(
|
|||
Given (among other things) an archive name, a database hook name, and a configured database
|
||||
configuration dict, restore that database from the archive.
|
||||
'''
|
||||
logger.info(f'{repository}: Restoring database {database["name"]}')
|
||||
logger.info(
|
||||
f'{repository.get("label", repository["path"])}: Restoring database {database["name"]}'
|
||||
)
|
||||
|
||||
dump_pattern = borgmatic.hooks.dispatch.call_hooks(
|
||||
'make_database_dump_pattern',
|
||||
hooks,
|
||||
repository,
|
||||
repository['path'],
|
||||
borgmatic.hooks.dump.DATABASE_HOOK_NAMES,
|
||||
location,
|
||||
database['name'],
|
||||
|
@ -87,7 +89,7 @@ def restore_single_database(
|
|||
# Kick off a single database extract to stdout.
|
||||
extract_process = borgmatic.borg.extract.extract_archive(
|
||||
dry_run=global_arguments.dry_run,
|
||||
repository=repository,
|
||||
repository=repository['path'],
|
||||
archive=archive_name,
|
||||
paths=borgmatic.hooks.dump.convert_glob_patterns_to_borg_patterns([dump_pattern]),
|
||||
location_config=location,
|
||||
|
@ -106,7 +108,7 @@ def restore_single_database(
|
|||
borgmatic.hooks.dispatch.call_hooks(
|
||||
'restore_database_dump',
|
||||
{hook_name: [database]},
|
||||
repository,
|
||||
repository['path'],
|
||||
borgmatic.hooks.dump.DATABASE_HOOK_NAMES,
|
||||
location,
|
||||
global_arguments.dry_run,
|
||||
|
@ -265,7 +267,7 @@ def run_restore(
|
|||
return
|
||||
|
||||
logger.info(
|
||||
f'{repository["path"]}: Restoring databases from archive {restore_arguments.archive}'
|
||||
f'{repository.get("label", repository["path"])}: Restoring databases from archive {restore_arguments.archive}'
|
||||
)
|
||||
|
||||
borgmatic.hooks.dispatch.call_hooks_even_if_unconfigured(
|
||||
|
@ -314,7 +316,7 @@ def run_restore(
|
|||
|
||||
found_names.add(database_name)
|
||||
restore_single_database(
|
||||
repository['path'],
|
||||
repository,
|
||||
location,
|
||||
storage,
|
||||
hooks,
|
||||
|
@ -343,7 +345,7 @@ def run_restore(
|
|||
database['name'] = database_name
|
||||
|
||||
restore_single_database(
|
||||
repository['path'],
|
||||
repository,
|
||||
location,
|
||||
storage,
|
||||
hooks,
|
||||
|
|
|
@ -25,7 +25,9 @@ def run_rinfo(
|
|||
repository, rinfo_arguments.repository
|
||||
):
|
||||
if not rinfo_arguments.json: # pragma: nocover
|
||||
logger.answer(f'{repository["path"]}: Displaying repository summary information')
|
||||
logger.answer(
|
||||
f'{repository.get("label", repository["path"])}: Displaying repository summary information'
|
||||
)
|
||||
|
||||
json_output = borgmatic.borg.rinfo.display_repository_info(
|
||||
repository['path'],
|
||||
|
|
|
@ -25,7 +25,7 @@ def run_rlist(
|
|||
repository, rlist_arguments.repository
|
||||
):
|
||||
if not rlist_arguments.json: # pragma: nocover
|
||||
logger.answer(f'{repository["path"]}: Listing repository')
|
||||
logger.answer(f'{repository.get("label", repository["path"])}: Listing repository')
|
||||
|
||||
json_output = borgmatic.borg.rlist.list_repository(
|
||||
repository['path'],
|
||||
|
|
|
@ -17,7 +17,9 @@ def run_transfer(
|
|||
'''
|
||||
Run the "transfer" action for the given repository.
|
||||
'''
|
||||
logger.info(f'{repository["path"]}: Transferring archives to repository')
|
||||
logger.info(
|
||||
f'{repository.get("label", repository["path"])}: Transferring archives to repository'
|
||||
)
|
||||
borgmatic.borg.transfer.transfer_archives(
|
||||
global_arguments.dry_run,
|
||||
repository['path'],
|
||||
|
|
|
@ -113,10 +113,14 @@ def run_configuration(config_filename, config, arguments):
|
|||
|
||||
while not repo_queue.empty():
|
||||
repository, retry_num = repo_queue.get()
|
||||
logger.debug(f'{repository["path"]}: Running actions for repository')
|
||||
logger.debug(
|
||||
f'{repository.get("label", repository["path"])}: Running actions for repository'
|
||||
)
|
||||
timeout = retry_num * retry_wait
|
||||
if timeout:
|
||||
logger.warning(f'{config_filename}: Sleeping {timeout}s before next retry')
|
||||
logger.warning(
|
||||
f'{repository.get("label", repository["path"])}: Sleeping {timeout}s before next retry'
|
||||
)
|
||||
time.sleep(timeout)
|
||||
try:
|
||||
yield from run_actions(
|
||||
|
@ -139,14 +143,14 @@ def run_configuration(config_filename, config, arguments):
|
|||
)
|
||||
tuple( # Consume the generator so as to trigger logging.
|
||||
log_error_records(
|
||||
f'{repository["path"]}: Error running actions for repository',
|
||||
f'{repository.get("label", repository["path"])}: Error running actions for repository',
|
||||
error,
|
||||
levelno=logging.WARNING,
|
||||
log_command_error_output=True,
|
||||
)
|
||||
)
|
||||
logger.warning(
|
||||
f'{config_filename}: Retrying... attempt {retry_num + 1}/{retries}'
|
||||
f'{repository.get("label", repository["path"])}: Retrying... attempt {retry_num + 1}/{retries}'
|
||||
)
|
||||
continue
|
||||
|
||||
|
@ -154,7 +158,8 @@ def run_configuration(config_filename, config, arguments):
|
|||
return
|
||||
|
||||
yield from log_error_records(
|
||||
f'{repository["path"]}: Error running actions for repository', error
|
||||
f'{repository.get("label", repository["path"])}: Error running actions for repository',
|
||||
error,
|
||||
)
|
||||
encountered_error = error
|
||||
error_repository = repository['path']
|
||||
|
|
Loading…
Reference in a new issue