"Unable to open config file" – Can I restore it?

Correct, it wasn’t a good test :wink:

The reason is that on restic init, restic generates new encryption keys, despite the same password is used.

Right. I misunderstood “same password” – I took that to mean that he used the same keys when (rather obviously, in hindsight) he meant that he typed the same password which would have created a new key.

In that case, I’d assume that simply using restic init in a new directory and copying the config file to the broken repository would be sufficient to fix the problem (enough to recover data, assuming no other repository problems) without having to patch restic. (Unless the config is encrypted with the master key?)

Interesting to read all that.

If the config File is not that important and a restore of data without it is somehow possible, than it would be nice to have a workaround for such situations in future versions maybe.

That’s the case, so it isn’t so easy.

I put together a quick & dirty patch:

It writes a new config file:

$ go run build.go && ./restic check --no-cache --verbose
repository  opened successfully, password is correct
create exclusive lock for repository
load indexes
check all packs
check snapshots, trees and blobs
no errors were found

I will test it with the real repository soon unless you see major problems with my patch @fd0 :wink: .

I used it on my “live” repo and it worked, config is back. Bad news though that restic check detects numerous missing data files and I suspect it is yet again a case of restic “detecting” faulty hardware :frowning: .

Thanks for your hints in this case @fd0, @betatester77, and @cdhowie!

2 Likes

A last-ditch effort would be to restic rebuild-index before running restic check, in case the files that are missing are indexes and not the actual packs.

@cdhowie Thanks, I tried that with not really encouraging results :frowning: .

Btw. it was a nice experience to build restic myself (git clone … && go run build.go, wait 20 seconds and boom! done!). Navigating the source was nice and I loved seeing it well documented and nicely split to smaller chunks of code :heavy_heart_exclamation: .