Restic init hallucinating on sftp backend

I ran the restic init command on sftp backend and it said that repo successfully created and it even allows me to make backups and list snapshots but there is no folder with repo on remote server. How to fix this?

Client terminal:

~/test > cat hello.txt
Hello World
~/test > restic --repo sftp://user@ip:/home/user/test/foobar --password-file .pw init
created restic repository e2e96b1781 at sftp://user@ip:/home/user/test/foobar

Please note that knowledge of your password is required to access
the repository. Losing your password means that your data is
irrecoverably lost.
~/test > restic --repo sftp://user@ip:/home/user/test/foobar --password-file .pw backup hello.txt
repository e2e96b17 opened (repository version 2) successfully, password is correct
created new cache in /home/user/.cache/restic
no parent snapshot found, will read all files

Files:           1 new,     0 changed,     0 unmodified
Dirs:            0 new,     0 changed,     0 unmodified
Added to the repository: 386 B (395 B stored)

processed 1 files, 12 B in 0:00
snapshot 14783cb8 saved
~/test > restic --repo sftp://user@ip:/home/user/test/foobar --password-file .pw snapshots
repository e2e96b17 opened (repository version 2) successfully, password is correct
ID        Time                 Host        Tags        Paths
-----------------------------------------------------------------------------------
14783cb8  2024-01-16 23:52:03  hostname                   /home/user/test/hello.txt
-----------------------------------------------------------------------------------
1 snapshots
~/test > restic --repo sftp://user@ip:/home/user/test/foobar --password-file .pw init
Fatal: create repository at sftp://user@ip:/home/user/test/foobar failed: config file already exists

Server terminal:

user@de:~/test$ pwd
/home/user/test
user@de:~/test$ ls
user@de:~/test$

No idea, but it is simply not possible that restic finds snapshots and does not complain that it cannot find a repository, if there aren’t files making up a repository and the snapshot file. Not to mention there has to be a key file for the authentication to work.

This is a problem outside of restic, you simply have to track down where your server stores those files :slight_smile: Perhaps make sure to check the absolute path /home/user/test/foobar on the server? The output only shows that you are checking in ~ and we don’t know for sure that ~ is really /home/user/. Just as an example.

Oh, i see. Because i specified / at the start of path it creates repo under /home/user/home/user/test/foobar

I’m guessing that your user’s SFTP session on the server is chrooted to their /home/user/, could this be accurate? According to the restic docs for the SFTP backend, when you specify an absolute path it’s expected to be absolute. It’s only when you don’t start the path with a / that it’s expected to be relative to the home directory. Or perhaps it’s a bug, although unlikely.