"Unable to open config file" โ€“ Can I restore it?

#1

Hello there,

I am unable to restore from my restic repository. It is located on an external hard disk. I have successfully mounted it yesterday to check that my data are there before I formatted (another) hard disk and reinstalled my linux box. Now I wanted to restore, but it fails due to a missing config file. When I created an empty repository for testing, it looked like a binary format? What does it contain? Can I restore the file or at least restore my data? I have the password at hand, how can I investigate this issue further?

[anton-pc restic]# echo $RESTIC_REPOSITORY                                                                       โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
/run/media/anton/Externe/restic PUblic BIlder/restic/                                                            โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
[anton-pc restic]# restic check                                                                                  โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
using temporary cache in /tmp/restic-check-cache-756117857                                                       โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
Fatal: unable to open config file: Stat: stat /run/media/anton/Externe/restic PUblic BIlder/restic/config: no sucโ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
h file or directory                                                                                              โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
Is there a repository at the following location?                                                                 โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
/run/media/anton/Externe/restic PUblic BIlder/restic/                                                            โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
[anton-pc restic]# restic snapshots                                                                              โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
Fatal: unable to open config file: Stat: stat /run/media/anton/Externe/restic PUblic BIlder/restic/config: no sucโ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
h file or directory                                                                                              โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
Is there a repository at the following location?                                                                 โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
/run/media/anton/Externe/restic PUblic BIlder/restic/
[anton-pc restic]# ls -la                                                                                        โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
insgesamt 148                                                                                                    โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
drwxrwxrwx 1 anton anton  4096 30. Apr 04:32 .                                                                   โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
drwxrwxrwx 1 anton anton     0  5. Mai 2018  ..                                                                  โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
drwxrwxrwx 1 anton anton 49152 30. Apr 04:33 data                                                                โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
drwxrwxrwx 1 anton anton 77824 26. Apr 08:06 index                                                               โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
drwxrwxrwx 1 anton anton     0  5. Mai 2018  keys                                                                โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
drwxrwxrwx 1 anton anton  4096 29. Apr 21:22 locks                                                               โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
drwxrwxrwx 1 anton anton 16384 26. Apr 08:06 snapshots 
[anton-pc restic]# restic version                                                                                โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
restic 0.9.5 compiled with go1.12.4 on linux/amd64
[anton-pc restic]# du -sh                                                                                        โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
352G    .            

Greetings from Germany,
The Dude

#2

Does anyone have an idea how to proceed here? @fd0 perhaps?

#3

So I am guessing by this that you have set the environment variable for your repository, right?
Can you post exactly how you have set it please? It might have to be that you have to escape the whitespace in your path.

#4

Hello Moritz,

thanks for your answer. I am sure that restic has picked up the (admittedly weird) path since it searched for its config file there:

Also the echo in the first line shows that it is evaluated as expected, right?

[anton-pc restic]# echo $RESTIC_REPOSITORY                                                                       โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
/run/media/anton/Externe/restic PUblic BIlder/restic/ 

Greetings!

#5

Have you tried to use the path to the repo manualy using quotes?

restic -r "/run/media/anton/Externe/restic PUblic BIlder/restic/" check
#6

Thanks for your answer. Yes, I have. I am just missing that config file, perhaps because the mount I used for checking the latest snapshot before was not cleanly closed. Is there documentation about what is in the config file, is there a way to recreate it or read the data blobs without it?

#7

okay, now I understand. Seems not to be a problem of whitespace in the path, instead the problem is that the file is indeed missing.

Unfortunately I donโ€™t know if it can be recreated.

#8

Exactly, that is what I suspect! Excuse me if I did not get it across clearly enough in my earlier postsโ€ฆ

#9

I played around a bit with some dummy data. Made a repo, deleted the config file, initalized a new repo at the same location with same password and similar tests. Nothing worked, all strategies gave cipher missmatch erros.

I am really not one of the experts here but I got the impression that this config file canโ€™t be recreated.

#10

Here is where restic creates the config:

Lines 38 and 43 generate random data. My suspicion is that losing the configuration file loses a necessary random value for decrypting any of its contents.

#11

bad news for me :frowning:

Would it make sense to keep a copy of that file in the same directory for those cases? I think btrfs does something similar for desaster recovery (having too root nodes)โ€ฆ

#12

I donโ€™t see any problems with doing that. It may also be a good idea to replicate the repository somewhere off-site for disaster recovery.

#13

Of course that always would be a good idea (full replication), but perhaps the config is important enough to replicate in restic and keep an unused copy or advise the user to save it when initializing a new repo? :thinking:

#14

Long story short: restic wonโ€™t work without the config file at the moment, but it only needs the values from the file for deduplication and cache management. So for reading data from the repo restic could work without the config file, but if you make new backups without the config file (or with a new one) youโ€™ll get a lot of duplicate data that restic cannot clean up.

@the_dude how important is the data in the repo for you? I can create a patch you can then use to recover the data, but I wonder if itโ€™s worth it.

Is there maybe a recover operation for the filesystem youโ€™re using (btrfs?) that can find the file again?

Iโ€™m also wondering: youโ€™ve only mounted the device for checking the repo, but restic wonโ€™t touch the config file after initializationโ€ฆ is the file system itself in a bad state? I canโ€™t imagine how a file would get lost without replacing it (or at least writing to it)โ€ฆ

#15

Perhaps. The same would apply to at least one key; if you lose all keys then you canโ€™t decrypt the master key anymore.

#16

Thank you very much for your answer, @fd0!

I guess it probably is not restic's fault, the system was in a bad state (booted from USB an chrooted to it to check the backup from there before rebuilding it), so it might well have been other reasons than restic reading or writing that file itself. The data are not super-critical, so I donโ€™t want to steal your time and would try myself first. Is it just about disabling this check for the purpose of reading and one-time restoring then? https://github.com/restic/restic/blob/7dcd2968b600a9014239e8ee0422518ee92ec5c0/cmd/restic/global.go#L627

The Dude

#17

No, thatโ€™s not enough: itโ€™s just the first check thatโ€™s there to print a better error message. Youโ€™d need to replace loading the config file (somewhere in repository/repository.go probably) with initializing a new one with new values for the ID and chunker polynomial.

#18

@fd0 Would that not lead to the same errors as indicated here?

#19

No, thatโ€™s different: when a new repository is initialized in the same location, restic generates new master keys for encryption and signing, which arenโ€™t compatible with the data thatโ€™s already there from the previous repository.

The config file only contains three fields:

  • repo version
  • chunker polynomial
  • ID for the repo (used for the cache directory name below ~/.cache/restic)

When the config file is missing (and restic is patched to generate random values on demand), the same master encryption/signing keys are used. Those are saved in each of the files below keys/. The decryption and verification will therefore still work as before.

#20

Ah, so the problem before was not the new config file, but that he used the new key generated by init instead of using one of the old keys.