/now
projects
ramblings
smol projects

restic env vars with cron

05.08.2023 1 min read

I managed a successful backup to Backblaze with Restic via the CLI, but my cron job wasn’t working. A quick glance at the logfile revealed this error:

Fatal: unable to open B2 backend: Account ID ($B2_ACCOUNT_ID) is empty

I double-checked the file to make sure everything was sourced correctly - it was. echo B2_ACCOUNT_ID printed just fine. So what was wrong? Well, it turns out that you need to export the environment variables to make them available to subprocesses.

  source /path/to/.env

  # this line is key
  export B2_ACCOUNT_ID
  export B2_ACCOUNT_KEY

References

Built with Astro and Tailwind 🚀