TypeError traceback with borgmatic create --json and database configured #563

Closed
opened 2022-07-19 16:25:26 +00:00 by witten · 4 comments
Owner

What I'm trying to do and why

Use the borgmatic create --json flag when a database happens to be configured for dumping, so I can use the JSON output from the backup in a downstream tool.

Steps to reproduce

  • Configure a database hook (MySQL, PostgreSQL, etc).
  • borgmatic create -c test.yaml -v 2 --json

Actual behavior

Ensuring legacy configuration is upgraded
test.yaml: No commands to run for pre-everything hook
borg --version --debug --show-rc
test.yaml: No commands to run for pre-backup hook
test.borg: Creating archive
test.borg: Calling postgresql_databases hook function remove_database_dumps
test.borg: Removing PostgreSQL database dumps
test.borg: Calling postgresql_databases hook function dump_databases
test.borg: Dumping PostgreSQL databases
test.borg: Dumping PostgreSQL database all to /root/.borgmatic/postgresql_databases/localhost/all
pg_dumpall --no-password --clean --if-exists --host localhost --username test > /root/.borgmatic/postgresql_databases/localhost/all
borg create --one-file-system --read-special --json test.borg::{hostname}-{now:%Y-%m-%dT%H:%M:%S.%f} /root/.borgmatic /root/tmp
Traceback (most recent call last):
  File "/usr/bin/borgmatic", line 33, in <module>
    sys.exit(load_entry_point('borgmatic', 'console_scripts', 'borgmatic')())
  File "/home/witten/code/borgmatic/borgmatic/commands/borgmatic.py", line 920, in main
    summary_logs = parse_logs + list(collect_configuration_run_summary_logs(configs, arguments))
  File "/home/witten/code/borgmatic/borgmatic/commands/borgmatic.py", line 813, in collect_configuration_run_summary_logs
    results = list(run_configuration(config_filename, config, arguments))
  File "/home/witten/code/borgmatic/borgmatic/commands/borgmatic.py", line 114, in run_configuration
    yield from run_actions(
  File "/home/witten/code/borgmatic/borgmatic/commands/borgmatic.py", line 350, in run_actions
    json_output = borg_create.create_archive(
  File "/home/witten/code/borgmatic/borgmatic/borg/create.py", line 323, in create_archive
    return execute_command_with_processes(
  File "/home/witten/code/borgmatic/borgmatic/execute.py", line 262, in execute_command_with_processes
    log_outputs(
  File "/home/witten/code/borgmatic/borgmatic/execute.py", line 102, in log_outputs
    logger.log(output_log_level, line)
  File "/usr/lib/python3.10/logging/__init__.py", line 1543, in log
    raise TypeError("level must be an integer")
TypeError: level must be an integer

Expected behavior

No traceback. Logging is suppressed at the console and only JSON output is produced.

Other notes / implementation ideas

execute_command_with_processes() probably needs a special case for when output_log_level is None (which is set when --json is used) similar to execute_command()'s existing case.

Original PR: https://github.com/borgmatic-collective/borgmatic/pull/47

Environment

borgmatic version: 1.6.5 / master

borgmatic installation method: pip

Borg version: 1.2.1

Python version: 3.10.5

Database version (if applicable): PostgreSQL 14.4, but occurs on MySQL as well.

operating system and version: Manjaro stable

#### What I'm trying to do and why Use the `borgmatic create --json` flag when a database happens to be configured for dumping, so I can use the JSON output from the backup in a downstream tool. #### Steps to reproduce * Configure a database hook (MySQL, PostgreSQL, etc). * `borgmatic create -c test.yaml -v 2 --json` #### Actual behavior ```python Ensuring legacy configuration is upgraded test.yaml: No commands to run for pre-everything hook borg --version --debug --show-rc test.yaml: No commands to run for pre-backup hook test.borg: Creating archive test.borg: Calling postgresql_databases hook function remove_database_dumps test.borg: Removing PostgreSQL database dumps test.borg: Calling postgresql_databases hook function dump_databases test.borg: Dumping PostgreSQL databases test.borg: Dumping PostgreSQL database all to /root/.borgmatic/postgresql_databases/localhost/all pg_dumpall --no-password --clean --if-exists --host localhost --username test > /root/.borgmatic/postgresql_databases/localhost/all borg create --one-file-system --read-special --json test.borg::{hostname}-{now:%Y-%m-%dT%H:%M:%S.%f} /root/.borgmatic /root/tmp Traceback (most recent call last): File "/usr/bin/borgmatic", line 33, in <module> sys.exit(load_entry_point('borgmatic', 'console_scripts', 'borgmatic')()) File "/home/witten/code/borgmatic/borgmatic/commands/borgmatic.py", line 920, in main summary_logs = parse_logs + list(collect_configuration_run_summary_logs(configs, arguments)) File "/home/witten/code/borgmatic/borgmatic/commands/borgmatic.py", line 813, in collect_configuration_run_summary_logs results = list(run_configuration(config_filename, config, arguments)) File "/home/witten/code/borgmatic/borgmatic/commands/borgmatic.py", line 114, in run_configuration yield from run_actions( File "/home/witten/code/borgmatic/borgmatic/commands/borgmatic.py", line 350, in run_actions json_output = borg_create.create_archive( File "/home/witten/code/borgmatic/borgmatic/borg/create.py", line 323, in create_archive return execute_command_with_processes( File "/home/witten/code/borgmatic/borgmatic/execute.py", line 262, in execute_command_with_processes log_outputs( File "/home/witten/code/borgmatic/borgmatic/execute.py", line 102, in log_outputs logger.log(output_log_level, line) File "/usr/lib/python3.10/logging/__init__.py", line 1543, in log raise TypeError("level must be an integer") TypeError: level must be an integer ``` #### Expected behavior No traceback. Logging is suppressed at the console and only JSON output is produced. #### Other notes / implementation ideas `execute_command_with_processes()` probably needs a special case for when `output_log_level` is None (which is set when `--json` is used) similar to `execute_command()`'s existing case. Original PR: https://github.com/borgmatic-collective/borgmatic/pull/47 #### Environment **borgmatic version:** 1.6.5 / master **borgmatic installation method:** pip **Borg version:** 1.2.1 **Python version:** 3.10.5 **Database version (if applicable):** PostgreSQL 14.4, but occurs on MySQL as well. **operating system and version:** Manjaro stable
witten added the
bug
label 2022-07-19 16:25:32 +00:00
Author
Owner

This has been fixed in master. With the fix in place, you can get JSON output even when a database is configured for dumping. This will be part of the next release!

This has been fixed in master. With the fix in place, you can get JSON output even when a database is configured for dumping. This will be part of the next release!

Wow thanks you very much! What speed !

Wow thanks you very much! What speed !
Author
Owner

This has been released in borgmatic 1.6.6!

This has been released in borgmatic 1.6.6!

It works perfectly thank you again 👍

It works perfectly thank you again 👍
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#563
No description provided.