Hey! I’m using restic to backup my laptop manually to my NAS using the restic server docker container. I’d like my backups to be unencrypted but for the restic server to have authentication. How can I achieve that?
I initialized the docker container on my NAS with this command: docker run -p 8000:8000 -v /share/Laptop:/share/Laptop --name rest_server --env DISABLE_AUTHENTICATION=1 -i -t restic/rest-server
And I initialized my repository: restic -r rest:http://tomodachi:8000/share/Laptop init --insecure-no-password
Everything currently works okay. However, I now removed --env DISABLE_AUTHENTICATION=1 from the docker run command, since I want to use authentication. I verified that the file /data/.htpasswd is there, I added a new user with the htpasswd command and verified that the password is correct (htpasswd -v). But when I try to run a restic backup (restic -r rest:http://tomodachi:8000/share/Laptop/ --insecure-no-password backup C:\Windows\Fonts), I get this output:
Fatal: unable to open config file: unexpected HTTP response (401): 401 Unauthorized
Is there a repository at the following location?
rest:http://tomodachi:8000/share/Laptop/
What I don’t get is, how am I supposed to provide the password? Shouldn’t the restic backup command prompt me for it? I’ve also tried setting RESTIC_REST_PASSWORD and RESTIC_REST_USERNAME as variables on the client side before running the restic backup command, but I got the same result. Any help is appreciated, thanks in advance!
You can specify the credentials in the repository URL as shown in Preparing a new repository — restic 0.18.0 documentation or using the environment variables you already suggested, RESTIC_REST_PASSWORD and RESTIC_REST_USERNAME.
If this isn’t working, make sure that you are on at least restic version 0.16.1 which is the version that first started supporting these environment variables. I highly recommend using the very latest restic version, which is currently 0.18.0, see Release restic 0.18.0 · restic/restic · GitHub .
If it’s still not working, then maybe your environment variables are not propagated to the restic processed, I guess. Make sure you export them or set them properly.
However, I also noticed that your docker run command only specifies one volume mount which is -v /share/Laptop:/share/Laptop. This doesn’t mount anything at the path /data inside the container, which is where rest-server in the container is looking for its data files. So given the information in your initial post, it seems that you neither provide the .htpasswd file to rest-server, nor actually persist the backups it stores. You should mount a volume at /data in the container, and make the .htpasswd file exist in that volume at path /data/.htpasswd.
Note that there are two credentials involved here - the one for accessing the REST server (specified in the repository URL as mentioned above) and then the password for your repository. Restic only prompts you for the latter of these (assuming you didn’t provide it using environment variables or arguments).