borg icon indicating copy to clipboard operation
borg copied to clipboard

Cover more common exceptions with errors

Open sophie-h opened this issue 3 years ago • 7 comments

There has been some user feedback where people were confused about what to do with some error messages. So I collected all the things about error messages that came to my mind.

Target not writeable for borg init

This has been an evergreen with missing permissions on USB drives. I guess this is easy to make a it a proper error with a msgid?

borg/repository.py\", line 248, in check_can_create_repository
st = os.stat(path)\nPermissionError: [Errno 13] Permission denied

Broken cache

I found those two, one after a power outage. Not sure how the other one happened. Both got fixed by deleting the cache. So it would be nice to give the option to delete the cache in the user interface in those cases.

However, they are both quite different. Not sure if there would be a good way to catch general cache issues and assign them a msgid?

raise Exception('%s does not look like a Borg cache.' % config_path)

and

"src/borg/hashindex.pyx", line 99, in borg.hashindex.IndexBase.__cinit__
ValueError: Could not read header (expected 18, but read 0 bytes)

Connection loss

This seems to happen when my system goes to sleep and backup is running and waking it up again. It does not trigger the usual ConnectionClosed(WithHint)

  File "/app/lib/python3.9/site-packages/borg/remote.py", line 709, in call
    for resp in self.call_many(cmd, [args], **kw):
  File "/app/lib/python3.9/site-packages/borg/remote.py", line 779, in call_many
    send_buffer()  # Try to send data, as some cases (async_response) will never try to send data otherwise.
  File "/app/lib/python3.9/site-packages/borg/remote.py", line 719, in send_buffer
    written = self.ratelimit.write(self.stdin_fd, self.to_send.peek_front())
  File "/app/lib/python3.9/site-packages/borg/remote.py", line 417, in write
    written = os.write(fd, to_send)
BrokenPipeError: [Errno 32] Broken pipe

ConnectionClosedWithHint

Somewhat related to errors: ConnectionClosedWithHint does not seem to be documented as msgid. It would be great if the hint could also be part of the error. But I haven't checked the code yet if there is a problem with that.

Repository.AtticRepository

I guess it would be great to have something similar in borg 1.2.x and borg 2.x to explain "install 2.0/1.2.x to use this repo" respectively?

sophie-h avatar Sep 10 '22 01:09 sophie-h

yeah, we can see if we can make some of them more user friendly (and still not losing potentially valuable error information).

borg 2.0 will not have any support any more for attic, that includes the attic repo detection.

ThomasWaldmann avatar Sep 10 '22 11:09 ThomasWaldmann

Maybe we can have this in borg 1.4 rather than in 2.0 - PRs welcome!

ThomasWaldmann avatar Dec 23 '23 18:12 ThomasWaldmann

Permission and broken pipe errors fixed by #8054 (1.4-maint).

ThomasWaldmann avatar Jan 20 '24 17:01 ThomasWaldmann

About other repo versions:

AtticRepository

Similar to below, should give error codes 2 (modern: 11).

Incompatible borg repo (like from borg2)

This already works:

% borg info /tmp/repo
/tmp/repo does not have a valid configuration. Check repo config [repository version 2 is not supported by this borg version].
% echo $?
2

% BORG_EXIT_CODES=modern borg info /tmp/repo
/tmp/repo does not have a valid configuration. Check repo config [repository version 2 is not supported by this borg version].
% echo $?                                     
16

ThomasWaldmann avatar Feb 08 '24 17:02 ThomasWaldmann

About corrupted caches / indexes:

Guess in such cases, there should be some manual investigation (not just a fully or semi automated "delete and recreate it").

Sometimes the root cause might be clearly known (like a power outage / system crash), but sometimes it might be also a hint for malfunctioning hardware, which should be investigated - so a full traceback might be useful.

ThomasWaldmann avatar Feb 08 '24 17:02 ThomasWaldmann

ConnectionClosed(WithHint):

should give rc 2 (modern: 80/81) and is documented now.

ThomasWaldmann avatar Feb 08 '24 17:02 ThomasWaldmann

So, guess this is done for 1.4-maint. TODO: check master.

ThomasWaldmann avatar Feb 08 '24 17:02 ThomasWaldmann