#367 Convert of old INI-Configfile fails because of missing YAML Rendering

Closed
opened 2 months ago by 0nelight · 3 comments

What I'm trying to do and why

I tried to convert an old INI-Config-File to the new YAML-Format but run into an Error that the file cannot be written because of the missing YAML Rendering.

Steps to reproduce

sudo upgrade-borgmatic-config -s ../borgmatic_config_files_old/backupconfig -d backupconfig.yaml

Actual behavior

sudo upgrade-borgmatic-config -s ../borgmatic_config_files_old/backupconfig -d backupconfig.yaml Traceback (most recent call last): File "/usr/local/bin/upgrade-borgmatic-config", line 8, in <module> sys.exit(main()) File "/usr/local/lib/python3.7/dist-packages/borgmatic/commands/convert_config.py", line 104, in main args.destination_config_filename, destination_config, mode=source_config_file_mode File "/usr/local/lib/python3.7/dist-packages/borgmatic/config/generate.py", line 128, in write_configuration config_file.write(rendered_config) TypeError: write() argument must be str, not CommentedMap

Other notes / implementation ideas

instead of this in /commands/convert_config.py:

destination_config = convert.convert_legacy_parsed_config(
	source_config, source_excludes, schema
	)

generate.write_configuration(
	args.destination_config_filename, destination_config, mode=source_config_file_mode
    )

this:

destination_config = convert.convert_legacy_parsed_config(
	source_config, source_excludes, schema
	)
 
destination_config = generate._render_configuration(destination_config)
 
generate.write_configuration(
	args.destination_config_filename, destination_config, mode=source_config_file_mode
    )

Environment

borgmatic version: 1.5.10

borgmatic installation method: pip

Borg version: 1.1.11

Python version: Python 3.7.3

operating system and version: Debian 10

#### What I'm trying to do and why I tried to convert an old INI-Config-File to the new YAML-Format but run into an Error that the file cannot be written because of the missing YAML Rendering. #### Steps to reproduce `sudo upgrade-borgmatic-config -s ../borgmatic_config_files_old/backupconfig -d backupconfig.yaml` #### Actual behavior `sudo upgrade-borgmatic-config -s ../borgmatic_config_files_old/backupconfig -d backupconfig.yaml Traceback (most recent call last): File "/usr/local/bin/upgrade-borgmatic-config", line 8, in <module> sys.exit(main()) File "/usr/local/lib/python3.7/dist-packages/borgmatic/commands/convert_config.py", line 104, in main args.destination_config_filename, destination_config, mode=source_config_file_mode File "/usr/local/lib/python3.7/dist-packages/borgmatic/config/generate.py", line 128, in write_configuration config_file.write(rendered_config) TypeError: write() argument must be str, not CommentedMap` #### Other notes / implementation ideas instead of this in [/commands/convert_config.py](https://projects.torsion.org/witten/borgmatic/src/commit/79bee755eed653c64a6a55a76b86695a10bb328f/borgmatic/commands/convert_config.py): ``` destination_config = convert.convert_legacy_parsed_config( source_config, source_excludes, schema ) generate.write_configuration( args.destination_config_filename, destination_config, mode=source_config_file_mode ) ``` this: ``` destination_config = convert.convert_legacy_parsed_config( source_config, source_excludes, schema ) destination_config = generate._render_configuration(destination_config) generate.write_configuration( args.destination_config_filename, destination_config, mode=source_config_file_mode ) ``` #### Environment **borgmatic version:** 1.5.10 **borgmatic installation method:** pip **Borg version:** 1.1.11 **Python version:** Python 3.7.3 **operating system and version:** Debian 10
0nelight closed this issue 2 months ago
0nelight reopened this issue 2 months ago
witten commented 2 months ago
Poster
Owner

Thank you so much for reporting this and tracking down the source of the problem! It looks like the write_configuration() function signature changed somewhere along the way, but convert_config.py wasn't ever updated to account for that. An integration test here would've been really useful.

Thank you so much for reporting this and tracking down the source of the problem! It looks like the `write_configuration()` function signature changed somewhere along the way, but `convert_config.py` wasn't ever updated to account for that. An integration test here would've been really useful.
witten added the
bug
label 2 months ago
witten commented 2 months ago
Poster
Owner

Fixed in master! Thanks again for reporting this.

Fixed in master! Thanks again for reporting this.
witten closed this issue 2 months ago
witten commented 2 months ago
Poster
Owner

Just released in borgmatic 1.5.11!

Just released in borgmatic 1.5.11!
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.