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 .
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.
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?
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.
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.
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)…
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?
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)…
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
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.
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.