bad character Local Exception #899

Closed
opened 2024-07-12 16:50:06 +00:00 by sshaikh · 9 comments

What I'm trying to do and why

The regular backup I make has suddenly started failing

Steps to reproduce

No response

Actual behavior

$ sudo borgmatic -c config.yaml
Sending message 'BORG: Finished backup to repo1:
35.496411 seconds
36 / 307270 files changed' 
Done!
Sending message 'BORG: Finished backup to repo2:
34.868918 seconds
36 / 307270 files changed' 
Done!
Local Exception
Traceback (most recent call last):
  File "borg/archiver.py", line 5401, in main
  File "borg/archiver.py", line 5321, in run
  File "borg/archiver.py", line 190, in wrapper
  File "borg/archiver.py", line 1395, in do_list
  File "borg/archiver.py", line 1403, in _list_archive
  File "borg/archiver.py", line 270, in build_matcher
  File "borg/patterns.py", line 128, in add_includepaths
  File "borg/patterns.py", line 128, in <listcomp>
  File "borg/patterns.py", line 357, in parse_pattern
  File "borg/patterns.py", line 190, in __init__
  File "borg/patterns.py", line 290, in _prepare
  File "re.py", line 252, in compile
  File "re.py", line 304, in _compile
  File "sre_compile.py", line 788, in compile
  File "sre_parse.py", line 955, in parse
  File "sre_parse.py", line 444, in _parse_sub
  File "sre_parse.py", line 599, in _parse
re.error: bad character range 4-1 at position 120

Platform: Linux nas 6.1.0-21-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.90-1 (2024-05-03) x86_64
Linux: Unknown Linux
Borg: 1.2.8  Python: CPython 3.9.19 msgpack: 1.0.8 fuse: llfuse 1.5.0 [pyfuse3,llfuse]

and in the rest of the output:

repo2: Error running actions for repository
Command '('borg', 'list', '--format', '{xxh64} /{path}{NL}', 'ssh://repo2 borg::xxx', 'file1', 'etc' ... )

Expected behavior

For the config to complete

Other notes / implementation ideas

No response

borgmatic version

1.8.12

borgmatic installation method

pipx

Borg version

1.2.8

Python version

3.9.19

Database version (if applicable)

No response

Operating system and version

Debian GNU/Linux 12 (bookworm)

### What I'm trying to do and why The regular backup I make has suddenly started failing ### Steps to reproduce _No response_ ### Actual behavior ``` $ sudo borgmatic -c config.yaml Sending message 'BORG: Finished backup to repo1: 35.496411 seconds 36 / 307270 files changed' Done! Sending message 'BORG: Finished backup to repo2: 34.868918 seconds 36 / 307270 files changed' Done! Local Exception Traceback (most recent call last): File "borg/archiver.py", line 5401, in main File "borg/archiver.py", line 5321, in run File "borg/archiver.py", line 190, in wrapper File "borg/archiver.py", line 1395, in do_list File "borg/archiver.py", line 1403, in _list_archive File "borg/archiver.py", line 270, in build_matcher File "borg/patterns.py", line 128, in add_includepaths File "borg/patterns.py", line 128, in <listcomp> File "borg/patterns.py", line 357, in parse_pattern File "borg/patterns.py", line 190, in __init__ File "borg/patterns.py", line 290, in _prepare File "re.py", line 252, in compile File "re.py", line 304, in _compile File "sre_compile.py", line 788, in compile File "sre_parse.py", line 955, in parse File "sre_parse.py", line 444, in _parse_sub File "sre_parse.py", line 599, in _parse re.error: bad character range 4-1 at position 120 Platform: Linux nas 6.1.0-21-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.90-1 (2024-05-03) x86_64 Linux: Unknown Linux Borg: 1.2.8 Python: CPython 3.9.19 msgpack: 1.0.8 fuse: llfuse 1.5.0 [pyfuse3,llfuse] ``` and in the rest of the output: ``` repo2: Error running actions for repository Command '('borg', 'list', '--format', '{xxh64} /{path}{NL}', 'ssh://repo2 borg::xxx', 'file1', 'etc' ... ) ``` ### Expected behavior For the config to complete ### Other notes / implementation ideas _No response_ ### borgmatic version 1.8.12 ### borgmatic installation method pipx ### Borg version 1.2.8 ### Python version 3.9.19 ### Database version (if applicable) _No response_ ### Operating system and version Debian GNU/Linux 12 (bookworm)
Owner

That error looks like it's coming from Borg itself. I'm guessing that you have the spot check enabled in borgmatic's configuration? What I'd recommend is try running borgmatic with --verbosity 2 to get the full Borg borg list --format ... command that borgmatic is running—or as much of it as it'll show you since it's probably really long. Then you can try running that Borg command directly to see if you can get the error to reproduce without borgmatic. If so, you'd have a good case to file a bug with the Borg project itself.

Hope that helps!

That error looks like it's coming from Borg itself. I'm guessing that you have the `spot` check enabled in borgmatic's configuration? What I'd recommend is try running borgmatic with `--verbosity 2` to get the full Borg `borg list --format ...` command that borgmatic is running—or as much of it as it'll show you since it's probably really long. Then you can try running that Borg command directly to see if you can get the error to reproduce without borgmatic. If so, you'd have a good case to file a bug with the Borg project itself. Hope that helps!
witten added the
question / support
label 2024-07-12 17:01:52 +00:00
Author

Running create, prune, compact, check separately resulted in a failed check, but then retrying that succeeded. So this seems transient.

If a check fails, should that take out the whole of borgmatic?

EDIT: whoops, didn't see the reply before posting. Yes, that seems in line. Will try to recreate the error consistently - I'm assuming there's no way to use the same spot that was used in the error case?

Running `create`, `prune`, `compact`, `check` separately resulted in a failed `check`, but then retrying that succeeded. So this seems transient. If a `check` fails, should that take out the whole of borgmatic? EDIT: whoops, didn't see the reply before posting. Yes, that seems in line. Will try to recreate the error consistently - I'm assuming there's no way to use the same `spot` that was used in the error case?
Owner

Running create, prune, compact, check separately resulted in a failed check, but then retrying that succeeded. So this seems transient.

Yeah, the spot check is probabilistic (more info here), so it makes sense that you'd see different results with different runs.

If a check fails, should that take out the whole of borgmatic?

check runs last (by default), so it doesn't prevent any of the other actions from completing even if the check fails. But borgmatic can only return a single exit code to the operating system, so if any of those steps fail, the entire borgmatic run fails. You can always run borgmatic actions individually (e.g., borgmatic check) if you don't want the failure of one action to impact the others.

EDIT: whoops, didn't see the reply before posting. Yes, that seems in line. Will try to recreate the error consistently - I'm assuming there's no way to use the same spot that was used in the error case?

Correct. But if you run it enough times, it should hopefully reproduce eventually!

> Running create, prune, compact, check separately resulted in a failed check, but then retrying that succeeded. So this seems transient. Yeah, the `spot` check is probabilistic ([more info here](https://torsion.org/borgmatic/docs/how-to/deal-with-very-large-backups/#spot-check)), so it makes sense that you'd see different results with different runs. > If a check fails, should that take out the whole of borgmatic? `check` runs last (by default), so it doesn't prevent any of the other actions from completing even if the `check` fails. But borgmatic can only return a single exit code to the operating system, so if any of those steps fail, the entire borgmatic run fails. You can always run borgmatic actions individually (e.g., `borgmatic check`) if you don't want the failure of one action to impact the others. > EDIT: whoops, didn't see the reply before posting. Yes, that seems in line. Will try to recreate the error consistently - I'm assuming there's no way to use the same spot that was used in the error case? Correct. But if you run it enough times, it should hopefully reproduce eventually!
Author

check found issues. Thanks for the tip - closing.

`check` found issues. Thanks for the tip - closing.
Owner

Sure thing.. Good luck with your repo!

Sure thing.. Good luck with your repo!

I hit this issue issue today and I think I found the problem. The file paths being passed to borg from the borgmatic spot check are of the form sh:/path/to/file. The sh: prefix tells borg to treat the pattern as a shell-style pattern, which includes things like [a..z] for ranges. In my case, I had a file path that looked structurally like some_text[zxy-cba]/more_text and borg (ultimately python's re module) complained that y-c was a bad character range. So I think we just want to drop the sh: prefix and have borg treat the paths as literals, not patterns.

I hit this issue issue today and I think I found the problem. The file paths being passed to borg from the borgmatic spot check are of the form `sh:/path/to/file`. The `sh:` prefix tells borg to treat the pattern as a shell-style pattern, which includes things like `[a..z]` for ranges. In my case, I had a file path that looked structurally like `some_text[zxy-cba]/more_text` and borg (ultimately python's re module) complained that `y-c` was a bad character range. So I think we just want to drop the `sh:` prefix and have borg treat the paths as literals, not patterns.
Owner

Good sleuthing! That makes sense to me. I'll reopen this ticket to cover that change.

Good sleuthing! That makes sense to me. I'll reopen this ticket to cover that change.
witten reopened this issue 2024-07-25 17:42:46 +00:00
witten added the
bug
label 2024-07-25 17:42:58 +00:00
Owner

This has been fixed in main and will be part of the next release!

This has been fixed in main and will be part of the next release!
Owner

Released in borgmatic 1.8.14!

Released in borgmatic 1.8.14!
Sign in to join this conversation.
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

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