borgbackup / borg

Deduplicating archiver with compression and authenticated encryption.
https://www.borgbackup.org/
Other
10.76k stars 735 forks source link

Crash when remote repo doesn't exist #8253

Closed lfam closed 1 week ago

lfam commented 1 week ago

Have you checked borgbackup docs, FAQ, and open GitHub issues?

Yes

Is this a BUG / ISSUE report or a QUESTION?

Bug / feature request

System information. For client/server mode post info for both machines.

Your borg version (borg -V).

Client: 1.4.0rc1 from Guix Server: 1.4.0rc1 from Guix

Operating system (distribution) and version.

Client: Debian Bookworm with Linux 5.15.160 Server: Debian Bookwork with Debian kernel 6.1.0-20-amd64

Hardware / network configuration, and filesystems used.

Client: Thinkpad x260, btrfs Server: PCEngines APU2, btrfs

How much data is handled by borg?

A few hundred gigabytes

Full borg commandline that lead to the problem (leave away excludes and passwords)

$ borg break-lock server-backup:/srv/backup/leo/client
Traceback (most recent call last):

  File "/gnu/store/1qy0rh3yxisn7a68kdwrg32g9m71p7fg-borg-1.4.0rc1/lib/python3.10/site-packages/borg/remote.py", line 252, in serve
    res = f(**args)

  File "/gnu/store/1qy0rh3yxisn7a68kdwrg32g9m71p7fg-borg-1.4.0rc1/lib/python3.10/site-packages/borg/remote.py", line 380, in open
    self.repository.__enter__()  # clean exit handled by serve() method

  File "/gnu/store/1qy0rh3yxisn7a68kdwrg32g9m71p7fg-borg-1.4.0rc1/lib/python3.10/site-packages/borg/repository.py", line 217, in __enter__
    self.open(self.path, bool(self.exclusive), lock_wait=self.lock_wait, lock=self.do_lock)

  File "/gnu/store/1qy0rh3yxisn7a68kdwrg32g9m71p7fg-borg-1.4.0rc1/lib/python3.10/site-packages/borg/repository.py", line 471, in open
    self.config.read_file(fd)

  File "/gnu/store/kgxbvcr9ks2k8lbm8fla7zvp63dbagrc-python-3.10.7/lib/python3.10/configparser.py", line 719, in read_file
    self._read(f, source)

  File "/gnu/store/kgxbvcr9ks2k8lbm8fla7zvp63dbagrc-python-3.10.7/lib/python3.10/configparser.py", line 1021, in _read
    for lineno, line in enumerate(fp, start=1):

OSError: [Errno 5] Input/output error

Borg server: Platform: Linux server 6.1.0-20-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.85-1 (2024-04-11) x86_64
Borg server: Linux: Unknown Linux  
Borg server: Borg: 1.4.0rc1  Python: CPython 3.10.7 msgpack: 1.0.4 fuse: llfuse 1.4.4 [pyfuse3,llfuse]
Borg server: PID: 3322048  CWD: /home/leo
Borg server: sys.argv: ['/gnu/store/1qy0rh3yxisn7a68kdwrg32g9m71p7fg-borg-1.4.0rc1/bin/.borg-real', 'serve', '--append-only', '--restrict-to-path', '/srv/backup/leo/']
Borg server: SSH_ORIGINAL_COMMAND: 'borg serve'
Platform: Linux client 5.15.160 #1 SMP Tue May 28 21:44:31 EDT 2024 x86_64
Linux: Unknown Linux  
Borg: 1.4.0rc1  Python: CPython 3.10.7 msgpack: 1.0.4 fuse: llfuse 1.4.4 [pyfuse3,llfuse]
PID: 2485  CWD: /home/leo/tmp/report
sys.argv: ['/gnu/store/1qy0rh3yxisn7a68kdwrg32g9m71p7fg-borg-1.4.0rc1/bin/.borg-real', 'break-lock', 'server-backup:/srv/backup/leo/client']
SSH_ORIGINAL_COMMAND: None

Describe the problem you're observing.

I didn't realize that the disk that contains the repository had become unmounted, and borg create was crashing, so I tried clearing any locks after checking that Borg was not running. It would be great if the client could be told that the repository could not be found, rather than crashing.

ThomasWaldmann commented 1 week ago

The problem is that all was going well (no "file or directory not found") until borg tried to read the repo config contents, which failed with an IOError.

IOError can be anything going wrong in the filesystem or on the storage media, so borg can't differentiate between the "repo not being mounted any more" and e.g. a disk read error.

lfam commented 1 week ago

That makes sense. I still think it would be nice to not crash here, from the user's perspective.

ThomasWaldmann commented 1 week ago

Well, there isn't much we can do there:

lfam commented 1 week ago

Understood, thanks