#10452·borg

Automatically keep a local backup of `repokey` keys

Author: PhrozenByteCreated Sep 28, 2026Updated Sep 28, 2026
Labelskeys

In the context of removing the none encryption modes in Borg 2, there was a short discussion in https://github.com/borgbackup/borg/issues/9104#issuecomment-5717841269 about whether repokey keys should be stored redundantly on the client.

With repokey, losing or corrupting the key file in the repo can make the repo inaccessible. The docs therefore recommend keeping an additional offsite copy of the key, but this is an easy step to overlook.

I'd like to discuss whether it would make sense for Borg to automatically keep an additional local copy of the repokey key that is not actively used, but kept solely as a backup.

Security considerations

Storing an additional copy of the key locally does not seem to significantly change the security situation. Arguably, an attacker could obtain the complete key material (repokey key + passphrase) in advance, but having the complete key material without the repo data to unlock is useless. As soon as the attacker gains access to the repo data, they can obtain the repokey key from the repo anyway. Thus, the additional copy primarily improves recoverability without materially reducing the security provided by repokey and its passphrase.

Notes

Details such as the exact location and format (it might simply mirror keyfile mode) and whether this should be automatic or configurable would need to be discussed.

Such a feature would make sense for both Borg 2 and Borg 1.4. For borg2 in particular it might be reasonable to create backups for all key files, not just the key that was used last.