Restic init attempt on backblaze returns 401 with no error message

Greetings,
First attempt to use restic with backblaze per this blog article:

When I try to init the repository, restic returns a 401:

$ restic -r b2:oryxBackup2 init
Fatal: create repository at b2:oryxBackup2 failed: b2.NewClient: b2_authorize_account: 
401:

I have followed the blog instructions and properly exported a key_id and key that I’ve created on backblaze.

I would expect a more specific message after the 401:, but there is none, so I don’t know quite where to take it from here to troubleshoot.

$ restic version
restic 0.9.5 compiled with go1.12.4 on linux/amd64

Any help appreciated!

401 is the HTTP code for “unauthorized,” which is coming from B2 – it is rejecting your credentials, or the credentials were not supplied. If you run the following two commands, do you see the expected key ID and secret? Are there any spaces around the double quotes in the output?

(Don’t paste the results here, though!)

echo \"$B2_ACCOUNT_ID\"
echo \"$B2_ACCOUNT_KEY\"

Hi cdhowie, thanks for the response.

Yep, my first thought was to double-check that my key_id and key were in their proper vars for restic to pick up, and they are in place as you suggested to check. Perhaps worth noting that it is an ‘Application Key’ in my backblaze acct, and has full permissions to do whatever it needs to do, so it’s puzzling that backblaze is returning a 401. Also, am I right in assuming that there should be some type of error msg following the “401:”?

To my knowledge, B2 returns 403 when the provided key does not have access to perform the requested operation. 401 indicates that there is a problem with the credentials themselves.

Argh, feeling a little silly now, I was trying to use an old key. Thanks for pointing me back to verifying my credentials!

1 Like

Hello @sdanieru, and welcome to the forum!

Don’t feel so bad, it happens to the best of us :wink: And thanks for keeping the topic posted. Perhaps mark it also as “Solved” would be a good idea?

Cheers,
– Durval.

Hi everyone
I have a similar problem, but not exactly the same. I get a 401 error when restic tries to remove the lock:
I first checked if the repository exist, then I created the repository and finally I tried to show the snapshots again. The same issue appears when I backup a file/directory or show the master key for example.

root@587469b95e8b:~# restic snapshots
Fatal: unable to open config file: Stat: b2_download_file_by_name: 404: File with such name does not exist.
Is there a repository at the following location?
b2:pg-backup:backup-test-restic-1/
root@587469b95e8b:~# echo $?
1
root@587469b95e8b:~# restic init
created restic repository feaa0ba007 at b2:pg-backup:backup-test-restic-1/

Please note that knowledge of your password is required to access
the repository. Losing your password means that your data is
irrecoverably lost.
root@587469b95e8b:~# restic snapshots
repository feaa0ba0 opened successfully, password is correct
created new cache in /app/pg-backup/.cache/restic
Remove(<lock/c887ed5465>) returned error, retrying after 552.330144ms: Delete: b2_delete_file_version: 401: 
Remove(<lock/c887ed5465>) returned error, retrying after 1.080381816s: Delete: b2_delete_file_version: 401: 
Remove(<lock/c887ed5465>) returned error, retrying after 1.31013006s: Delete: b2_delete_file_version: 401: 
Remove(<lock/c887ed5465>) returned error, retrying after 1.582392691s: Delete: b2_delete_file_version: 401: 
Remove(<lock/c887ed5465>) returned error, retrying after 2.340488664s: Delete: b2_delete_file_version: 401: 
Remove(<lock/c887ed5465>) returned error, retrying after 4.506218855s: Delete: b2_delete_file_version: 401: 
Remove(<lock/c887ed5465>) returned error, retrying after 3.221479586s: Delete: b2_delete_file_version: 401: 
Remove(<lock/c887ed5465>) returned error, retrying after 5.608623477s: Delete: b2_delete_file_version: 401: 
Remove(<lock/c887ed5465>) returned error, retrying after 7.649837917s: Delete: b2_delete_file_version: 401: 
Remove(<lock/c887ed5465>) returned error, retrying after 15.394871241s: Delete: b2_delete_file_version: 401: 
Remove(<lock/c887ed5465>) returned error, retrying after 507.606314ms: Delete: b2_delete_file_version: 401: 
Remove(<lock/c887ed5465>) returned error, retrying after 985.229971ms: Delete: b2_delete_file_version: 401: 
Remove(<lock/c887ed5465>) returned error, retrying after 803.546856ms: Delete: b2_delete_file_version: 401: 
Remove(<lock/c887ed5465>) returned error, retrying after 1.486109007s: Delete: b2_delete_file_version: 401: 
Remove(<lock/c887ed5465>) returned error, retrying after 2.070709754s: Delete: b2_delete_file_version: 401: 
Remove(<lock/c887ed5465>) returned error, retrying after 3.67875363s: Delete: b2_delete_file_version: 401: 
Remove(<lock/c887ed5465>) returned error, retrying after 4.459624189s: Delete: b2_delete_file_version: 401: 
Remove(<lock/c887ed5465>) returned error, retrying after 6.775444383s: Delete: b2_delete_file_version: 401: 
Remove(<lock/c887ed5465>) returned error, retrying after 15.10932531s: Delete: b2_delete_file_version: 401: 
Remove(<lock/c887ed5465>) returned error, retrying after 13.811796615s: Delete: b2_delete_file_version: 401: 
error in cleanup handler: Delete: b2_delete_file_version: 401: 

I configured the credentials and the repository via environment variables.
The account I use has the following capabilities in b2:
writeFiles,readFiles,listFiles,deleteFiles

Do you have any ideas what I am missing?