borgbackup / borg

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

borg2 repo-info / repo-list with rclone on non-existing repo leaves behind lock directory in repo path #8485

Closed witten closed 6 days ago

witten commented 6 days ago

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

Yes.

Is this a BUG / ISSUE report or a QUESTION?

BUG / ISSUE

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

Your borg version (borg -V).

Client: Borg 2.0.0b12 (only using Borg locally for this ticket)

Operating system (distribution) and version.

Manjaro stable 24.1.1

Hardware / network configuration, and filesystems used.

Lenovo X1 Carbon, no network, ext4

How much data is handled by borg?

None.

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

$ rm -fr test.borg
$ borg2.0.0b12 repo-info --json --repo rclone://test.borg

Describe the problem you're observing.

After the above commands:

$ ls -lR test.borg
test.borg:
total 4
drwx------ 2 root root 4096 Oct 23 10:49 locks

test.borg/locks:
total 0

It appears that either Borg or rclone are leaving behind an empty locks directory within the previously non-existent repo path. This is a problem because borgmatic uses repo-info to probe for whether a repo exists prior to running repo-create—but repo-create fails if anything already exists in the repo path. Therefore this locks directory prevents borgmatic's use of repo-create from ever succeeding.

The repo-list subcommand also leaves behind a locks directory.

Can you reproduce the problem? If so, describe how. If not, describe troubleshooting steps you took before opening the issue.

Yes.

Include any warning/errors/backtraces from the system logs

Local Exception

Error:

ObjectNotFound: Not Found: error 404: {
    "error": "failed to find object: object not found",
    "input": null,
    "path": "config/readme",
    "status": 404
}

If reporting bugs, please include the following:

Traceback (most recent call last):
  File "borg/archiver/__init__.py", line 633, in main
  File "borg/archiver/__init__.py", line 527, in run
  File "borg/archiver/_common.py", line 151, in wrapper
  File "borg/repository.py", line 161, in __enter__
  File "borg/repository.py", line 223, in open
  File "borgstore/store.py", line 170, in load
  File "borgstore/backends/rclone.py", line 238, in load
  File "borgstore/backends/rclone.py", line 150, in _requests
borgstore.backends.errors.ObjectNotFound: Not Found: error 404: {
    "error": "failed to find object: object not found",
    "input": null,
    "path": "config/readme",
    "status": 404
}

Platform: Linux flux 6.1.112-1-MANJARO #1 SMP PREEMPT_DYNAMIC Mon Sep 30 19:15:46 UTC 2024 x86_64
Linux: Unknown Linux  
Borg: 2.0.0b12  Python: CPython 3.12.6 msgpack: 1.1.0 fuse: llfuse 1.5.1 [pyfuse3,llfuse]
PID: 666547  CWD: /root/tmp
sys.argv: ['/root/borg2.0.0b12', 'repo-info', '--json', '--repo', 'rclone://test.borg']
SSH_ORIGINAL_COMMAND: None

Note that the traceback itself is probably fixed in #8475.

ThomasWaldmann commented 6 days ago

Relevant code:

https://github.com/borgbackup/borg/blob/2.0.0b12/src/borg/repository.py#L211

Guess we need to move lock creation to after trying to read config/readme - the readme contents is currently used to determine whether there is a borg repository.

Or maybe even to after the version check right after that.

If there is no repo yet (or it is a unsupported repo version), it will abort there, before creating the lock.

The lock itself is removed by the context manager, but not the containing directory.

witten commented 6 days ago

Thanks!