Borg: Warning: Attempting to access a previously unknown unencrypted repository!

Created on 27 Jan 2016  路  10Comments  路  Source: borgbackup/borg

Hi,

We are trying to automate borg deployment and addition of backup nodes via Ansible. The borg repository is created by the borg-server, and when the borg-client connects (via SSH) to borg for the first time Borg gets stuck at Warning: Attempting to access a previously unknown unencrypted repository!, and requires interaction from the user.

But in our case, the backups are ran from cron and no user interaction is possible, therefore Borg will be stuck forever.

Is there a command line option to override this warning? The documentation doesn't say anything on this.

Thanks,

Rik

Most helpful comment

Borg uses the environment variable $HOME to find the home directory. This is not set in the cron shell environment. Try adding the line
export HOME=/root
to your backup script, before running borg.

All 10 comments

See there:

http://borgbackup.readthedocs.org/en/stable/usage.html#environment-variables

Use these carefully. Especially if you use encryption, overriding this warning creates a security risk.

Hi,

I have the same issue on a local machine - when trying to backup to a repository via cron I get the message Warning: Attempting to access a previously unknown unencrypted repository. When I call the script manually, it works fine.
Where does borg store the info whether a repository is known or unknown ?

Thank you.

Where does borg store the info whether a repository is known or unknown ?

In the cache ($HOME/.cache/borg)

Cron user and the user who created the repo are probably different?

Cron runs in a different context indeed.
Can I safely just copy the borg cache dir to the other user's home or is there another recommended way to make a repository known to borg (besides forcing auto-yes via environment as suggested above - a solution I would like to circumvent) ?
Thanks again.

  • Can copy the cache dir (specifically: ~/.cache/borg/[repo id]/ ; the repo id is in the "config" file in the repository)
  • Could run the script once with su/sudo to get things started
  • Run once with the yes-env-var

Borg uses the environment variable $HOME to find the home directory. This is not set in the cron shell environment. Try adding the line
export HOME=/root
to your backup script, before running borg.

Running my script, now with $HOME env set, did not work as intended. I had to login as the user, run the script, confirm, and log out again - then it worked using cron.

@nizedk what is did not work as intended precisely?

Also please note that this ticket is closed, so maybe rather open a new one and provide way more information.

Personal experience: init and initial backups run from root shell, more backups from vixie-cron job (as root), failure when I switched to fcron (still running job as root). Problem went away when I put export HOME=/root in the backup script as @bjorkegeek suggested. Thanks!

Had the same issue today. Adding export HOME=/root doesn't work for me. But export BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=yes as mentoned by Thomas here works like a charm.

I use anacron that run in non-root mode. So I dont need sudo borg except backup for / directory.

Thanks lot for borg.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tconstans picture tconstans  路  5Comments

russelldavis picture russelldavis  路  3Comments

htho picture htho  路  5Comments

phdoerfler picture phdoerfler  路  6Comments

auanasgheps picture auanasgheps  路  5Comments