With "borgmatic check", consider Borg warnings as errors (#247).
This commit is contained in:
parent
d99e6d1994
commit
2cc743cf47
7 changed files with 22 additions and 11 deletions
5
NEWS
5
NEWS
|
@ -1,3 +1,8 @@
|
||||||
|
1.4.12
|
||||||
|
* #247: With "borgmatic check", consider Borg warnings as errors.
|
||||||
|
* Dial back the display of inline error logs a bit, so failed command output doesn't appear
|
||||||
|
multiple times in the logs (well, except for the summary).
|
||||||
|
|
||||||
1.4.11
|
1.4.11
|
||||||
* #241: When using the Healthchecks monitoring hook, include borgmatic logs in the payloads for
|
* #241: When using the Healthchecks monitoring hook, include borgmatic logs in the payloads for
|
||||||
completion and failure pings.
|
completion and failure pings.
|
||||||
|
|
|
@ -126,7 +126,7 @@ def check_archives(
|
||||||
+ (repository,)
|
+ (repository,)
|
||||||
)
|
)
|
||||||
|
|
||||||
execute_command(full_command)
|
execute_command(full_command, error_on_warnings=True)
|
||||||
|
|
||||||
if 'extract' in checks:
|
if 'extract' in checks:
|
||||||
extract.extract_last_archive_dry_run(repository, lock_wait, local_path, remote_path)
|
extract.extract_last_archive_dry_run(repository, lock_wait, local_path, remote_path)
|
||||||
|
|
|
@ -390,7 +390,9 @@ def make_error_log_records(message, error=None):
|
||||||
except CalledProcessError as error:
|
except CalledProcessError as error:
|
||||||
yield log_record(levelno=logging.CRITICAL, levelname='CRITICAL', msg=message)
|
yield log_record(levelno=logging.CRITICAL, levelname='CRITICAL', msg=message)
|
||||||
if error.output:
|
if error.output:
|
||||||
yield log_record(levelno=logging.CRITICAL, levelname='CRITICAL', msg=error.output)
|
yield logging.makeLogRecord(
|
||||||
|
dict(levelno=logging.CRITICAL, levelname='CRITICAL', msg=error.output)
|
||||||
|
)
|
||||||
yield log_record(levelno=logging.CRITICAL, levelname='CRITICAL', msg=error)
|
yield log_record(levelno=logging.CRITICAL, levelname='CRITICAL', msg=error)
|
||||||
except (ValueError, OSError) as error:
|
except (ValueError, OSError) as error:
|
||||||
yield log_record(levelno=logging.CRITICAL, levelname='CRITICAL', msg=message)
|
yield log_record(levelno=logging.CRITICAL, levelname='CRITICAL', msg=message)
|
||||||
|
|
|
@ -57,10 +57,10 @@ tests](https://torsion.org/borgmatic/docs/how-to/extract-a-backup/).
|
||||||
|
|
||||||
## Error hooks
|
## Error hooks
|
||||||
|
|
||||||
When an error occurs during a backup, borgmatic can run configurable shell
|
When an error occurs during a backup or another action, borgmatic can run
|
||||||
commands to fire off custom error notifications or take other actions, so you
|
configurable shell commands to fire off custom error notifications or take
|
||||||
can get alerted as soon as something goes wrong. Here's a not-so-useful
|
other actions, so you can get alerted as soon as something goes wrong. Here's
|
||||||
example:
|
a not-so-useful example:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
hooks:
|
hooks:
|
||||||
|
@ -91,9 +91,10 @@ here:
|
||||||
* `output`: output of the command that failed (may be blank if an error
|
* `output`: output of the command that failed (may be blank if an error
|
||||||
occurred without running a command)
|
occurred without running a command)
|
||||||
|
|
||||||
Note that borgmatic does not run `on_error` hooks if an error occurs within a
|
Note that borgmatic runs the `on_error` hooks for any action in which an error
|
||||||
`before_everything` or `after_everything` hook. For more about hooks, see the
|
occurs, not just the `create` action. But borgmatic does not run `on_error`
|
||||||
[borgmatic hooks
|
hooks if an error occurs within a `before_everything` or `after_everything`
|
||||||
|
hook. For more about hooks, see the [borgmatic hooks
|
||||||
documentation](https://torsion.org/borgmatic/docs/how-to/add-preparation-and-cleanup-steps-to-backups/),
|
documentation](https://torsion.org/borgmatic/docs/how-to/add-preparation-and-cleanup-steps-to-backups/),
|
||||||
especially the security information.
|
especially the security information.
|
||||||
|
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -1,6 +1,6 @@
|
||||||
from setuptools import find_packages, setup
|
from setuptools import find_packages, setup
|
||||||
|
|
||||||
VERSION = '1.4.11'
|
VERSION = '1.4.12'
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
|
|
|
@ -9,7 +9,9 @@ from ..test_verbosity import insert_logging_mock
|
||||||
|
|
||||||
|
|
||||||
def insert_execute_command_mock(command):
|
def insert_execute_command_mock(command):
|
||||||
flexmock(module).should_receive('execute_command').with_args(command).once()
|
flexmock(module).should_receive('execute_command').with_args(
|
||||||
|
command, error_on_warnings=True
|
||||||
|
).once()
|
||||||
|
|
||||||
|
|
||||||
def insert_execute_command_never():
|
def insert_execute_command_never():
|
||||||
|
|
|
@ -129,6 +129,7 @@ def test_make_error_log_records_generates_output_logs_for_message_only():
|
||||||
|
|
||||||
def test_make_error_log_records_generates_output_logs_for_called_process_error():
|
def test_make_error_log_records_generates_output_logs_for_called_process_error():
|
||||||
flexmock(module).should_receive('log_record').replace_with(dict)
|
flexmock(module).should_receive('log_record').replace_with(dict)
|
||||||
|
flexmock(module.logging).should_receive('makeLogRecord').replace_with(dict)
|
||||||
|
|
||||||
logs = tuple(
|
logs = tuple(
|
||||||
module.make_error_log_records(
|
module.make_error_log_records(
|
||||||
|
|
Loading…
Reference in a new issue