Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BackendAlreadyExists: rclone storage base path already exists on emtpy dir #57

Closed
bjo81 opened this issue Sep 27, 2024 · 8 comments
Closed
Milestone

Comments

@bjo81
Copy link

bjo81 commented Sep 27, 2024

As discussed with @ThomasWaldmann on IRC who told me to ping @ncw:

borg2 --debug repo-create -e repokey-chacha20-poly1305  --copy-crypt-key  --repo rclone://fsn:borg2store/mail  --from-borg1 --other-repo rclone://sb:mail                  
                                                                                                                                                                                              
using builtin fallback logging configuration                                                                                                                                                  
19 self tests completed in 0.05 seconds                                                                                                                                                       
Starting new HTTP connection (1): 127.0.0.1:35507                                                                                                                                             
http://127.0.0.1:35507 "POST /operations/stat HTTP/11" 200 93                                                                                                                                 
Local Exception                                                                                                                                                                               
                                                                                                                                                                                              
Error:                                                                                                                                                                                        
                                                                                                                                                                                              
BackendAlreadyExists: rclone storage base path already exists: fsn:borg2store/mail/                                                                                                           
                                                                                                                                                                                              
If reporting bugs, please include the following:                                                                                                                                              
                                                                                                                                                                                              
Traceback (most recent call last):                                                             
  File "borg/archiver/__init__.py", line 623, in main                                                                                                                                         
  File "borg/archiver/__init__.py", line 517, in run                                                                                                                                          
  File "borg/archiver/_common.py", line 151, in wrapper                                                                                                                                       
  File "borg/repository.py", line 148, in __enter__                                                                                                                                           
  File "borg/repository.py", line 162, in create                                                                                                                                              
  File "borgstore/store.py", line 65, in create                                                                                                                                               
  File "borgstore/backends/rclone.py", line 163, in create                                                                                                                                    
borgstore.backends.errors.BackendAlreadyExists: rclone storage base path already exists: fsn:borg2store/mail/                                                                                 

But it's empty:

rclone ls fsn:borg2store
root@mail /tmp # 

The bucket was freshly created and it's nothing in there.

@ncw
Copy link
Contributor

ncw commented Sep 27, 2024

The tests for the backends encourage backends to throw the BackendAlreadyExists if the directory for the backend already exists.

In this case the directory is the borg2store bucket.

I'm not sure this is absolutely correct or sensible though - what do you think @ThomasWaldmann ?

Should rclone only raise this error if the destination has something in it? For use with s3, people often create the buckets in advance and then don't give rclone enough permissions to create buckets.

Possible workarounds for you @bjo81

  • delete the bucket and let rclone create it - rclone may not have permissions to do this though
  • use a subdirectory of the bucket to store the backup fsn:borg2store/mybackup

@bjo81
Copy link
Author

bjo81 commented Sep 27, 2024

@ThomasWaldmann also thought it's related to the existing bucket, but as already quoted:

 rclone storage base path already exists: fsn:borg2store/mail/

and the bucket is empty, so it should be possible to create the "mail" directory in it.

@ThomasWaldmann
Copy link
Member

Guess the point of the other backends raising if the base dir exists is because for them (fs, sftp), an existing directory means that "there is already something". A bit more precise would be to only raise if there is an existing non-empty directory I guess.

@ThomasWaldmann
Copy link
Member

@bjo81 yeah, we seem to have 2 issues here:

  • it should not complain about the existing bucket dir
  • it complains also when using a non-existing dir

@ThomasWaldmann
Copy link
Member

I am working on fixing the tests, guess it will become something like this:

def test_already_exists(tested_backends, request):
    backend = get_backend_from_fixture(tested_backends, request)
    with backend:
        backend.store("key", b"value")  # make the backend "not empty"
    # the backend must reject (re-)creation if there is already something at that place
    with pytest.raises(BackendAlreadyExists):
        backend.create()

@ncw
Copy link
Contributor

ncw commented Sep 27, 2024

I am working on fixing the tests, guess it will become something like this:

I think that works better, and it fixes the problem with s3 directories not existing unless they have files in.

@ncw
Copy link
Contributor

ncw commented Sep 27, 2024

@ThomasWaldmann give me a ping when you've updated the test and I'll send a PR for the rclone backend to fix.

ThomasWaldmann added a commit to ThomasWaldmann/borgstore that referenced this issue Sep 27, 2024
we shouldn't check just for the base directory and reject
if it exists, that is troublesome for cloud storages.

also, it is not really a problem if we just use an empty
filesystem or sftp directory - we should only reject if
there is stuff inside.
ThomasWaldmann added a commit that referenced this issue Sep 27, 2024
backend.create: only reject non-empty storage, see #57
@ThomasWaldmann
Copy link
Member

Fixed by #62.

@ThomasWaldmann ThomasWaldmann added this to the 0.0.5 milestone Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants