Backing up to Backblaze with root priveleges?

I’ve been using Restic to B2 for a couple years now and it’s worked great, however, I’m changing my backup strategy and I’ve hit some snags.

My new backup flow includes two backups to an external HDD: 1) a restic script backing up my user data 2) a Timeshift schedule backing up files owned by BOTH root and a user named “bob”. The second stage of my backup flow is to then use Restic to backup the entire HDD to Backblaze.

The immediate issue I have is I can’t seem to run the Backblaze backup command without error because when I attempt to run the backup as root, it doesn’t see the environment variables required. I can set the environment variables at user bob’s level but apparently not as root. I’m assuming since I’m now trying to backup the Timeshift data described above that I must backup as root to have the priveleges required to both backup and restore properly but correct me if I’m wrong.

Here’s a screen capture:

root@pop-os:/media/bob/RED_BACKUP# export B2_ACCOUNT_ID=xxx
export B2_ACCOUNT_KEY=xxx
root@pop-os:/media/bob/RED_BACKUP# sudo restic -r b2:bucketname:foldername --verbose backup /media/bob/RED_BACKUP
open repository
Fatal: unable to open B2 backend: Account ID ($B2_ACCOUNT_ID) is empty

Any guidance in how to achieve my goal is greatly appreciated!

Hmmm, many people have seen the question but no suggestions. I’m wondering if what I’m asking is even possible?

Just drop the sudo and it’ll work. No need to sudo when you’re root and sudo doesn’t preserve the environment by default:

[root@pc ~]# export FOO=bar
[root@pc ~]# sudo env | grep FOO
[root@pc ~]# sudo --preserve-env env | grep FOO
[root@pc ~]#

Also, see the warning about Backblaze at:

1 Like

My concern is that if I back up files that are owned by root, restoring them will be a problem since the permissions may have issues on the restored files. I’ll build a small test case to see how that goes before doing the full backup, which will take days to complete. Thanks.

If you run sudo as root user, then you’re still root afterwards. restore will be able to properly set the file permissions, if it is run by the root user.