Restic not running with root user (Backblaze)

Hi all

I’m running restic 0.9.6 on my local Ubuntu 20.04. All credentials are properly stored in /etc/environment as follows:

B2_ACCOUNT_ID=1234
B2_ACCOUNT_KEY=1234
RESTIC_REPOSITORY=b2:test-backup:folder1       
RESTIC_PASSWORD=1234

This works flawlessly. However, if I try to run a backup with root instead of my own user, It cannot access the B2 bucket for some reason. For example executing sudo restic snapshots results in:

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:test-backup:folder1       

If I execute the same without sudo, it shows all my snapshots. First I thought that root user has no access to the variables defined in /etc/environment. However, If I execute echo $B2_ACCOUNT_ID with user root, it correctly shows the content, so the variables are available.

I’m lost. Do you have any ideas! Any help appreciated :slight_smile:

Kind regards,

Tom

Please first of all update to and try it with the latest restic version which is 0.12.1, you can download it on the release page here: https://github.com/restic/restic/releases/tag/v0.12.1

does sudo env also show all necessary variables?

Please be aware that storing the B2 and restic credentials in a file that is readable by anything running on that system is a rather bad idea. I’d recommend to create file only readable by e.g. the root user and the sourcing that file before running restic.

Thanks for all the hints!

@rawtaz: I upgraded to the newest version

@MichaelEischer: sudo env finally led to the problem. Somehow not all env variables were loaded correctly. I set them again and it works now. I also moved the password to a separate file.

Again, thanks for helping out :slight_smile: