What happens when a new keyfile repo is created at the same path?
@mowny https://github.com/borgbackup/borg/issues/6204#issuecomment-1028744422
What if a keyfile exists when a new repo is created?
- Alice creates a keyfile repo at $REPO
- The repo is moved or unmounted
- Alice creates another keyfile repo at the same location
- What happenes?
- Is the existing key reused?
- Is the existing key overwritten?
A new key is created:
$ borg init -e keyfile ~/collision
$ mv ~/collision ~/foo
$ borg init -e keyfile ~/collision
$ mv ~/collision ~/bar
$ borg init -e keyfile ~/collision
$ ls ~/.config/borg/keys/
home_user_collision
home_user_collision.2
home_user_collision.3
It appears that we do not have a regression test to cover this edge case. I could add one. Should I also add a paragraph to faq or borg init docs?
It seems to be handled correctly, though, and the correct key is used. (Does it test all existing keyfiles until one is found that fits?)
IIRC, the repo ID is used to identify the right key. And when generating the key filename, it uses a new name, even the repo path is the same.
We could also store the repo key under REPOID.key or so, maybe that would smell less like a problem.
I renamed the keyfile, and borg found it anyway, so it really seems to try all files in there.
@hexagonrecursion yes, a test and docs would be nice.