Due to mistyping, I accidentally initiated deletion of the directory where I keep my repository directories, as opposed to just deleting the single repository that I wanted to delete.
After , I now have some intact repositories, some corrupted ones (seen with restic check --read-data), and at least one that is completely gone.
As part of a layered backup strategy, I do nightly restic copy of my repositories to off-site Restic repositories, and have just discovered that I don’t actually know how to use those to recover (yes, regular restore tests must be done as part of any backup, and I do feel quite embarrassed that I have failed in that respect — scold me if you must, but please help afterwards).
Thus, I have two questions:
How do I get the fully gone repo(s) back from the off-site backup?
Is this just a matter of reversing the direction of restic copy?
If so, I imagine that I need to do a restic init first, but is there more?
If not, what then?
How do I get the partially deleted repo data back for the repos affected by that?
Is this also just a matter reversing the direction of restic copy?
If not, what then?
Also, are there any caveats that I could easily fail to be aware of?
Restic version is restic 0.18.1 compiled with go1.25.1 on linux/amd64 and I don’t know if it would be good or bad to upgrade before the recovery attempt.
If you have enough space available locally, think about leaving the broken repos as they are and recover the remote ones to a new folder locally. This way you keep a maximum of data you currently have available.
One way to transfer the remote repos to your local space (and the way I’d do it) is using rsync and then check if everything is there, do repo checks, see if all important snapshots are there etc.
Then you might think about using that copy locally to go on. If something is missing in those, check if you can complete with data from the old, local folder.
Alternatively if you want to use restic copy, make new repos locally (restic init and all) and then restic copy what you need to those. Just make sure you leave the old, broken repos like they are as long as possible and until you know you have everything you need working in the remote location.
I would make a new repository locally (restic init, with --copy-chunker-params from the remote) then run a copy operation from the remote repository to the local.
Given you don’t know exactly how much of the repository was damaged/lost, personally I’d start over with a fresh repository, and run a restic copy to it, same as for the fully deleted repositories. Keep the partially deleted repositories around until after you’ve got the data copied back down if possible.
However, if avoiding copying everything from the remote is a high priority to you, you could try a reverse copy to the existing partially deleted local repository, and then do a restic check with the --read-data flag set to ensure all the pack files are in place. I’m not sure if or how well this will work though, I think it depends entirely on what state the partially deleted repository is in.
I also don’t know how well copy copes with parent snapshots that are missing data etc, there’s no --force flag like there is with restic backup. Maybe someone with more knowledge of the restic internals can speak to this? Perhaps any damaged snapshots need to be removed first (i.e. the repository should be repaired)?
Restic is fully backwards compatible, so I’d personally upgrade first. That way you benefit from the latest bugfixes/enhancements etc.
Thank you both, @nicnab and @shd2h , especially for such swift replies!
I shall see what I can do about space to preserve the damaged damaged, and then decide on whether to do init --copy-chunker-data + copy, or whether to simply copy the dirs wholesale (in my case, that would be rclone instead of rsync, due the the remotes being on cloud storage).
As I read it, you both recommend, if at all possible, to avoid copying into the damaged repos, so in that case, the rsync/rclone way might be the easiest.