Had the first big data loss scare of my linux life today when three directories of files I need for work and life in general, and that I keep synced across a number of machines with syncthing, were suddenly empty across all my machines (for reasons that are still mysterious to me). I had set up borg backups around a year ago that run every night via cron, but, against all the good advice out there, I had never practiced actually restoring files from them. Today it took just a few minutes ddg’ing to figure out how to restore the directories and it worked like a charm. I am once again amazed and grateful at all this incredible community-supported software.
IMO, Borg is the best Linux backup utility for serious data protection.
Glad it worked out for you.
It would be helpful if you could describe the way to restore the data. I’m a borg
user, too (and I added a little 'matic by using borgmatic
). I did some simple dry runs with rsync in order to be prepared for the worst to come.
OK, I’m not very practiced in writing linux tutorials, but I’ll take a whack at it…
I have an rpi that I use as a syncthing server of sorts, which is to say that all the data directories I share between machines link back to the rpi so that I have single point from which to do backups. A cronjob uses borg to do nightly backups from the rpi to the hard drive on another machine (called backup-machine
in the commands below) using ssh.
So to restore, I first got on the rpi and listed the backups that are stored on the backup-machine:
borg list ssh://drhoopoe@backup-machine:/home/drhoopoe/.backups/rpi
This gave me a list of all the backups (and yeah, I know it’s odd and maybe a bad idea to keep the backups from one machine in the home directory of another, but that’s how it’s set up currently). I then used borg extract
with the --dry-run
and --list
flags to see if the files I’m missing were still present in last night’s backup:
borg extract --dry-run --list ssh://drhoopoe@backup-machine:/home/drhoopoe/.backups/rpi::rpi-2022-01-22T22:30:02 home/drhoopoe/Documents/Name_of_lost_directory
It lists all the files that would be restored if it weren’t a dry run, and they’re the ones I’m looking for, so I then run the command again without the --dry-run
flag:
borg extract --list ssh://drhoopoe@backup-machine:/home/drhoopoe/.backups/rpi::rpi-2022-01-22T22:30:02 home/drhoopoe/Documents/Name_of_lost_directory
And wa-la, I have my files back on the rpi and thus, via syncthing, on my other machines too.
Perfect! Thanks a lot!