I’m trying to use the password-file option to read my b2 credentials, but I’m running into a little trouble.
When I run restic with --password-file /home/me/passwd.txt
it returns the message:
"Fatal: unable to open B2 backend: Account ID ($B2_ACCOUNT_ID) is empty.
If I don’t specify the repo with the -r flag, but instead try to read that from the passwd.txt file, it gives me the message:
“Fatal: Please specify repository location”
So, it appears that restic is not accessing the passwd.txt file at all.
Can someone tell me the proper way to use the password-file flag? What is the correct syntax to use for the credentials in the password file?
If I read the documentation correctly the password-file is meant to contain nothing but the password. You must not place anything else in there.
If you want to save all information in a file you can
Contents of credentials.txt:
On the command line:
user@client:~$ source credentials.txt
user@client:~$ restic backup /path/to/files
Also the user you run the restic command as must be able to read the password file. Make sure that the permissions are set correctly.
Yeah, now that I read the documentation correctly, I think you’re right.
Thanks for setting me straight!
I’m glad you figured it out, thanks @moritzdietz for the help!
If you have any idea on how to improve the documentation (e.g. wording, adding a setence or so), please let us know!
I’m trying to set up restic with B2 right now and I’m running into the same issue. Here’s my (incomplete) suggestion for the documentation.
In this section it currently says:
You need to first setup the following environment variables with the credentials you can find in the dashboard on the “Buckets” page when signed into your B2 account:
$ export B2_ACCOUNT_ID=<MY_APPLICATION_KEY_ID>
$ export B2_ACCOUNT_KEY=<MY_APPLICATION_KEY>
Immediately underneath I would have expected something like this:
Instead of passing the B2 credentials as environment variables, restic can read them from a file. For this you need to call it with these two parameters:
restic --password-file=./my-b2-password --something-file=./my-b2-account-id
As you can see I haven’t found out how to pass the account ID yet.
Edit: Actually I haven’t found out how to pass the account key either because apparently
--password-file=... does not read it from the file - even when I set it, I still get an error:
Fatal: create repository at failed: Fatal: unable to open B2 backend: Key ($B2_ACCOUNT_KEY) is empty
--password-file is for the backup encryption password. I’m an idiot.
What confused me was that there simply seems to be no way to specify B2 credentials by file. That’s a bit unexpected.