From 325f53c286c66c3e4da8af2e37dcd5046ebbc1f8 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Tue, 11 Mar 2025 14:07:06 -0700 Subject: [PATCH] Context tweaks + mention configuration upgrade in command hook documentation (#1019). --- borgmatic/commands/borgmatic.py | 8 ++++---- .../add-preparation-and-cleanup-steps-to-backups.md | 13 +++++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/borgmatic/commands/borgmatic.py b/borgmatic/commands/borgmatic.py index 7ed854f8..b7c6ad52 100644 --- a/borgmatic/commands/borgmatic.py +++ b/borgmatic/commands/borgmatic.py @@ -103,7 +103,7 @@ def run_configuration(config_filename, config, config_paths, arguments): dry_run=global_arguments.dry_run, action_names=arguments.keys(), configuration_filename=config_filename, - log_file=arguments['global'].log_file, + log_file=arguments['global'].log_file or '', ): try: local_borg_version = borg_version.local_borg_version(config, local_path) @@ -243,7 +243,7 @@ def run_configuration(config_filename, config, config_paths, arguments): config.get('umask'), global_arguments.dry_run, configuration_filename=config_filename, - log_file=arguments['global'].log_file, + log_file=arguments['global'].log_file or '', repository=error_repository.get('path', '') if error_repository else '', repository_label=error_repository.get('label', '') if error_repository else '', error=encountered_error, @@ -834,7 +834,7 @@ def collect_configuration_run_summary_logs(configs, config_paths, arguments): config.get('umask'), arguments['global'].dry_run, configuration_filename=config_filename, - log_file=arguments['global'].log_file, + log_file=arguments['global'].log_file or '', ) except (CalledProcessError, ValueError, OSError) as error: yield from log_error_records('Error running before everything hook', error) @@ -896,7 +896,7 @@ def collect_configuration_run_summary_logs(configs, config_paths, arguments): config.get('umask'), arguments['global'].dry_run, configuration_filename=config_filename, - log_file=arguments['global'].log_file, + log_file=arguments['global'].log_file or '', ) except (CalledProcessError, ValueError, OSError) as error: yield from log_error_records('Error running after everything hook', error) diff --git a/docs/how-to/add-preparation-and-cleanup-steps-to-backups.md b/docs/how-to/add-preparation-and-cleanup-steps-to-backups.md index 33a6593a..c6d8c854 100644 --- a/docs/how-to/add-preparation-and-cleanup-steps-to-backups.md +++ b/docs/how-to/add-preparation-and-cleanup-steps-to-backups.md @@ -38,8 +38,13 @@ commands: - echo "Something went wrong!" ``` -If a `run:` command contains a special YAML character such as a colon, you may -need to quote the entire string (or use a [multiline +If you're coming from an older version of borgmatic, there is tooling to help +you [upgrade your +configuration](https://torsion.org/borgmatic/docs/how-to/upgrade/#upgrading-your-configuration) +to this new command hook format. + +Note that if a `run:` command contains a special YAML character such as a colon, +you may need to quote the entire string (or use a [multiline string](https://yaml-multiline.info/)) to avoid an error: ```yaml @@ -61,8 +66,8 @@ Each command in the `commands:` list has the following options: * `when`: Only trigger the hook when borgmatic is run with particular actions (`create`, `prune`, etc.) listed here. Defaults to running for all actions. * `run`: List of one or more shell commands or scripts to run when this command hook is triggered. -Note that borgmatic does not run `error` hooks if an error occurs within an -`everything` hook. +borgmatic does not run `error` hooks if an error occurs within an `everything` +hook. There's also another command hook that works a little differently: