I would like to employ some safety measures to my project in case some dependency suddenly goes offline. Specifically, those dependencies that are plain git repositories. But since I am already at it, I thought I could just do it for all dependencies, also those on crates.io.
Specifically, I would like to back up all source code from the whole dependency tree specified by a Cargo.lock
file. And be able to "restore" that backup somehow.
For restoring, I care less about how much work it is. I expect if a crate goes offline, I could just manually go into the backup, take its source code and put it into a git repository. Then I can specify that as a dependency in cargo. Even if the dependency tree contains multiple versions of a crate, that should not be too much work.
But for backing up I don't know what the best solution would be. I googled a bit, but couldn't find any tool. It seems like I can't just back up some subdirectory of the target
directory, because it only contains pointers to the .cargo
directory, which contains the actual source code.
Can I somehow make cargo write the sources of all dependencies into some directory? Or did anyone else solve the same problem and would be so kind and share how they did it?