REST server (dev) problems with a particular repo path /data/

Compiled rest server from repo.
rest-server version rest-server 0.10.0-dev compiled with go1.16.7 on linux/amd64

Scratching my head on this one.

If I init a repo as data/ the rest server throws errors.
if I init it is as say _data/ then all this fine. In fact anything but the path data

If I then rename _data to data and try to write to it, problems so it’s not just the init command but any command using that particular path including /data. I evened renamed to _data_ and no problems.

whether I run via command line or systemd service sudo or no issue is the same
sudo /opt/bin/restic-server --listen 0.0.0.0:9500 --path /backup --no-auth --debug

Why would one particular directory name cause problems?? Is this a bug?? Running on linux ubuntu 20.04.
Anyone want to try this with rest server compiled from source?

sudo RESTIC_PASSWORD=xxx /opt/bin/restic -r rest:https://backup.xxx.net/giskard/data init
Fatal: create repository at rest:https://backup.xxx.net/giskard/data/ failed: Fatal: server response unexpected: 405 Method Not Allowed (405)

POST /giskard/data/?create=true

sudo RESTIC_PASSWORD=xxx /opt/bin/restic -r rest:https://backup.xxx.net/giskard/_data init
created restic repository 9792f9df85 at rest:https://backup.xxx.net/giskard/_data/

Please note that knowledge of your password is required to access
the repository. Lo
sudo RESTIC_PASSWORD=xxx /opt/bin/restic -r rest:https://backup.xxx.net/giskard/data -H giskard backup /data --iexclude-file /data/exclude.bac
run this command? y
Fatal: unable to open config file: <config/> does not exist
Is there a repository at the following location?
rest:https://backup.xxx.net/giskard/data/

running server with --debug did not provide any insight
HEAD /giskard/data/config

Looks like you’re trying to initialize a repository at a user-specific URL (unless I’m misunderstanding “giskard”), in which case you should probably be using the --private-repos option.

That said, the behavior you’re seeing is simply because certain path components are special and are therefore not allowed to be used as the folder name for your repository. data is one of them, and you can see them all listed here: https://github.com/restic/rest-server/blob/master/repo/repo.go#L96

The reason they’re special is because they are the default folder names that a restic repository contains, so they’re protected in order to not accidentally create a repository “on top of” a part of another repository.

So there’s no bug in this case, what you’re seeing is per design and code, it’s simply a safety measure. It might however be unexpected since it’s not clear anywhere that this is the case, so perhaps we should add it to the README.

2 Likes