Bare-metal backup/restore with Restic?

I’m running Fedora 43 (KDE) and I want to use Restic to back up my workstation’s two drives. The drive that contains my /home folder (a 4TB SATA SSD) will be a simple file-backup to an external drive (and to Backblaze B2), and I’m pretty sure I understand how to set that one up.

The main boot drive, though (a 2TB NVMe SSD) – that, I’m not quite certain how to do yet.

I have Snapper installed on my machine, and it makes regular snapshots of that boot-drive (yes, it’s BTRFS – both my drives are, actually) so I can reboot and select an old snapshot if an update borks my system. Can Restic simply back up one of those snapshots as an image? Or does Restic need to do its own snapshots?

My goal is to have a bare-metal recovery USB stick – with Fedora 43 and Restic installed on it – that will allow me to boot to that stick, run Restic to restore onto a new SSD, and have my machine back up and running in ~1 hour, should should my boot SSD fail.

Oh, and in that vein – how do I install Restic’s restore utilities onto a bootable Fedora 43 USB stick? dnf isn’t gonna work, because when you boot to a live USB stick, it’s a read-only filesystem. So how do I get Restic to write itself to that stick in the appropriate place?

Sorry for the potentially noob questions – I did search and couldn’t really find what I was looking for, at least not a recent post, anyway. Closest thing I found was way back in 2019, and there’s no way that’s still relevant 7 years later. LOL. And he didn’t really give step-by-step instructions – just said that he was able to do a bare-metal recovery and gave general steps, but I need something more specific, since I’m not really familiar with Restic.

Any help you can give will be appreciated. Thanks!

A simple and fast way to backup and restore linux file systems is to use fsarchiver (https://www.fsarchiver.org/) available in most distros and as part of the system rescue bootable iso package ( SystemRescue - System Rescue Homepage ). No need to exclude virtual filesystems such as /proc. Restore can be to smaller or larger partitions, BTRFS is supported, along with most other linux filesystems. Compression and encryption are options.

BTW, I’m a strong supporter and long-time user of restic, brilliant software, but I like to use the best tool for the job at hand.

Hey, welcome to the forum :slight_smile:

The answer is a bit of both. You can read the output from btrfs send into restic using --stdin-from-command, which stores the btrfs snapshot as a single file in a restic snapshot:

The backup workflow looks a bit like this:

  • Create btrfs snapshot (you can skip this as snapper does it for you): sudo btrfs subvol snapshot -r /mnt/btrfs/my_subvol/ /mnt/btrfs_snaps/1
  • Backup btrfs snapshot into restic: sudo restic -r /srv/restic-repo backup --stdin-from-command -- btrfs send /mnt/btrfs_snaps/1

To restore, use restic dump to pipe the stored snapshot file into btrfs recieve, which unpacks it into a subvol again:

  • sudo restic -r /srv/restic-repo backup dump latest /stdin | sudo btrfs receive /mnt/btrfs/my_new_subvol/

Note that the file that is the btrfs snapshot is just called “/stdin” by default. You could rename it if you wanted using the --stdin-filename flag when creating the restic snapshot, but you’ll need to take care to use the same filename when restoring.
Also note I used the special snapshot ID “latest” when restoring in the example above, you could select a specific snapshot to restore from as needed.

One downside to this approach is restic has to scan the entire snapshot each time, as it is a single large file. This could take a long time if the snapshot is large, and the system making the backup is not that powerful; anecdotally I saw about 15s backup time for 0.5Gb of snapshot data when doing some quick testing, and this doesn’t decrease for subsequent snapshots.
restic does deduplicate the btrfs snapshots very well though.

Note that by itself this isn’t a complete bare-metal recovery solution. E.g. you would need to re-install Fedora before restoring the snapshot to have something to restore the snapshot to.