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

2.0.0b10 - OSError when using sftp: repository #8373

Open
bket opened this issue Sep 10, 2024 · 5 comments
Open

2.0.0b10 - OSError when using sftp: repository #8373

bket opened this issue Sep 10, 2024 · 5 comments
Labels

Comments

@bket
Copy link
Contributor

bket commented Sep 10, 2024

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

Yes

Is this a BUG / ISSUE report or a QUESTION?

Bug

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

Your borg version (borg version).

2.0.0b10 / 2.0.0b10

Operating system (distribution) and version.

OpenBSD amd64 current

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

borg -r sftp://bket@gateway:22/tmp/test create $(date +%s) /home/bket

Describe the problem you're observing.

When creating a backup using a sftp: repository I see the following:

kerberos$ borg -r sftp://bket@gateway:22/tmp/test create $(date +%s) /home/bket
Enter passphrase for key ssh://bket@gateway:22/tmp/test:
Local Exception

Error:

OSError: Failure

If reporting bugs, please include the following:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/borg/archiver/__init__.py", line 622, in main
    exit_code = archiver.run(args)
                ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/borg/archiver/__init__.py", line 516, in run
    rc = func(args)
         ^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/borg/archiver/_common.py", line 176, in wrapper
    return method(self, args, repository=repository, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/borg/archiver/create_cmd.py", line 268, in do_create
    create_inner(archive, cache, fso)
  File "/usr/local/lib/python3.11/site-packages/borg/archiver/create_cmd.py", line 202, in create_inner
    archive.save(comment=args.comment, timestamp=args.timestamp)
  File "/usr/local/lib/python3.11/site-packages/borg/archive.py", line 661, in save
    self.manifest.write()
  File "/usr/local/lib/python3.11/site-packages/borg/manifest.py", line 435, in write
    self.repository.put_manifest(robj)
  File "/usr/local/lib/python3.11/site-packages/borg/repository.py", line 450, in put_manifest
    return self.store.store("config/manifest", data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/borgstore/store.py", line 107, in store
    self.backend.store(self.find(name), value)
  File "/usr/local/lib/python3.11/site-packages/borgstore/backends/sftp.py", line 168, in store
    self.client.rename(tmp_name, name)
  File "/usr/local/lib/python3.11/site-packages/paramiko/sftp_client.py", line 423, in rename
    self._request(CMD_RENAME, oldpath, newpath)
  File "/usr/local/lib/python3.11/site-packages/paramiko/sftp_client.py", line 857, in _request
    return self._read_response(num)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/paramiko/sftp_client.py", line 909, in _read_response
    self._convert_status(msg)
  File "/usr/local/lib/python3.11/site-packages/paramiko/sftp_client.py", line 942, in _convert_status
    raise IOError(text)
OSError: Failure

Platform: OpenBSD kerberos.lan 7.6 GENERIC.MP#101 amd64
Borg: 2.0.0b10  Python: CPython 3.11.9 msgpack: 1.0.8 fuse: None [pyfuse3,llfuse]
PID: 99000  CWD: /home/bket
sys.argv: ['/usr/local/bin/borg', '-r', 'sftp://bket@gateway:22/tmp/test', 'create', '1725944775', '/home/bket']
SSH_ORIGINAL_COMMAND: None

A check if the backup has been made results in the following error:

kerberos$ borg -r sftp://bket@gateway:22/tmp/test repo-list
Enter passphrase for key ssh://bket@gateway:22/tmp/test:
Cache, or information obtained from the security directory is newer than repository - this is either an attack or unsafe (multiple repos with same ID)

After removing the local security dir (.local/borg) everything seems fine:

kerberos$ borg -r sftp://bket@gateway:22/tmp/test repo-list
Enter passphrase for key ssh://bket@gateway:22/tmp/test:
1725944775                           Tue, 2024-09-10 07:06:19 +0200 [4e2a394c8102476665d57acec8b674dfbb1e668944974dbdb881c68cb2f89893]
@ThomasWaldmann
Copy link
Member

Hmm, that is a borgstore sftp backend issue. I thought it only happens with the macOS builtin sftp server (and not with e.g. OpenSSH), but looks like that was wrong.

I'll make a borgstore 0.0.2 release ASAP, so you can test if calling client.posix_rename instead of client.rename fixes it for OpenBSD / OpenSSH also.

That sftp server you use is OpenSSH, right?

@ThomasWaldmann
Copy link
Member

Likely fixed in borgstore 0.0.2:

https://github.com/borgbackup/borgstore/blob/master/CHANGES.rst

@bket
Copy link
Contributor Author

bket commented Sep 10, 2024

That sftp server you use is OpenSSH, right?

Yes, server uses OpenSSH.

Issue is fixed with borgstore-0.0.2. Works for me. Thank you!

Let me check: is the format for the storage URL described somewhere? Reason for asking is that one needs to include a user in the url, e.g., user@host/path. Without it there is a ValueError, In other words, setting sftp://user@host/path as --repo works, setting sftp://host/pathdoes not.

$ borg -r sftp://gateway/tmp/test create $(date +%s) /home/bket
Local Exception

Error:

ValueError: Invalid Backend Storage URL: sftp://gateway/tmp/test

If reporting bugs, please include the following:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/borg/archiver/__init__.py", line 622, in main
    exit_code = archiver.run(args)
                ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/borg/archiver/__init__.py", line 516, in run
    rc = func(args)
         ^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/borg/archiver/_common.py", line 138, in wrapper
    repository = get_repository(
                 ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/borg/archiver/_common.py", line 50, in get_repository
    repository = Repository(
                 ^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/borg/repository.py", line 107, in __init__
    self.store = Store(url, levels={"config/": [0], "data/": [2]})
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/borgstore/store.py", line 42, in __init__
    raise ValueError(f"Invalid Backend Storage URL: {url}")
ValueError: Invalid Backend Storage URL: sftp://gateway/tmp/test

Platform: OpenBSD kerberos.lan 7.6 GENERIC.MP#101 amd64
Borg: 2.0.0b10  Python: CPython 3.11.9 msgpack: 1.0.8 fuse: None [pyfuse3,llfuse]
PID: 13905  CWD: /home/bket
sys.argv: ['/usr/local/bin/borg', '-r', 'sftp://gateway/tmp/test', 'create', '1725964122', '/home/bket']
SSH_ORIGINAL_COMMAND: None

@ThomasWaldmann
Copy link
Member

OK, looks like 2 remaining issues:

  • should raise some BE specific error so borg can catch that and not have an ugly traceback
  • should have the user part optionally (will need to check if that works with paramiko)

The borg docs were updated with working URLs, there is a specific section about that:

https://borgbackup.readthedocs.io/en/master/usage/general.html#repository-urls

@ThomasWaldmann
Copy link
Member

borgstore 0.0.3 now has the user part optional and also can read ssh configuration now.

also raises a BE specific exception for borg to catch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants