borg
borg copied to clipboard
What are use cases for key import for repokey based repo?
I understand the use case for importing a missing or corrupted key for a keyfile based repo, but I fail to see in what circumstances import would be useful for for repokey scenario. There is other data in the config file besides the key, so if the config file were to be corrupted or lost an import is of little use.
In fact I tested by renaming config, and as expected the import failed.
Please forgive me if I'm missing the blindingly obvious.
maybe it currently can only cope with the (unlikely?) case that your key got removed from the config somehow. the other repo params are easy to reconstruct by looking at the dirs/files below data/ in a case of emergency (or, if you used the defaults, copy&paste + check from another repo's config).
but I agree, it could be more useful by doing that by itself when there is no config at all.
did you try whether key import works if you just removed the key from the config?
did you try whether key import works if you just removed the key from the config?
Thanks. I just have. It imports the key if you just remove the key.
On the basis that the id is also part of the keyfile and equally likely to be 'corrupted', if I remove the id as well, I get an exception when I import the keyfile in configparser.py (KeyError: 'id'), followed by another exception in archiver.py (configparser.NoOptionError: No option 'id' in section: 'repository'). I'd have hoped it restored the id as well.
(This is 1.0.9 from macports BTW)
I accept this is a bit of an artificial scenario!
The id isn't important, the rest of the config file, except the key, can be recovered manually (all settings are the default ~99 % of the time, and for the other 1 % you can guess). I suppose "borg check --repository-only" could be extended to deal with corrupted config files and guess settings, then a key can be imported ("--ignore-repository-id"?).
Would --ignore-repository-id
also allow to import a key from one repo into another one?
Say, e.g., that you want to move your backup repo from one place to another. However, for some reason (e.g. bec. it is too much data to move and recreating it is faster), you decided to delete the old repo. You, however, still have (a backup) of the keyfile. Now, you may still have printed your keyfile and put it far away in a safe place, so you want to avoid having to replace it by printing yet another one and replacing the old one.
So you maybe want to export the keyfile from the old repo and import it into a new one created with borg init
…
No, that's not a good idea. It is the same case as copying an encrypted repository and updating both copies independently (just that one copy is not around any more); it's not secure.
A secure way to do this would be to debug get-obj
the manifest from the old repo, import --iri, debug put-obj on the new repo.
Okay, but that's not really a thing a "usual" user would do. Also I don't really understand why that is secure (is not it essentially the same as copying the repo or, at least, the keyfile and some metadata.)
So maybe better don't allow the user to do this. :smiley:
As this is not specific to 1.0.x, I am moving this to 1.1.x milestone.