Hetzner full partition backup with Restic

I’m looking for advice or step-by-step guidance on performing a full disk backup using Restic while in Hetzner Cloud Rescue Mode. My main goal is to have a backup that can be easily restored without too much effort.

Has anyone successfully done this? If so, could you share the steps or tips to make the process smooth and reliable?

Any detailed follow-up steps would be highly appreciated!

1 Like

I haven’t personally done that yet but the basic idea should work. I just checked if you can copy the restic binary to the rescue system’s /usr/bin folder and that works. So all you should have to do is use one of restic’s “–stdin” options to dd the device you want to backup to restic (probably /dev/sda1) and then put that in a repository of your choice.

The only thing I’m not too sure about is whether that is actually very practical as you have to take down your server on every backup and you have to read the whole device on every backup. Deduplication should make snapshots fairly small but I’m also not too optimistic about speed in this setup.

Why not just dd/gz the image to a backup location from time to time and make a backup of the actual data within the machine using restic?

1 Like

or even better use software which is designed to do it maybe? something like veeam which has free option for example.

Sounds proprietary :laughing:

Definitely will look into this, it seems more easy and has option to backup to CIFS Storage Box, Veeam has option to backup via SCP SSH or SFTP. Also,

However, @nicnab dd if/of also easy as mostly famous for! But might be Veeam can do auto-incremental backups with schedule.

If this is a Linux system and you use rescue mode, you might also consider just backing up the whole file system of the machine in question. After a full restore you’ll have to rebuild your grub setup, very likely in a chroot jail. That should be reasonably fast. But I agree, it is not very practical, you have to do lots of manual steps.

Small update for @wCORS : Out of academic interest I just tested dd’ing the rescue disk hdd to a local computer and directly backing it up to restic. It does seem to work but I didn’t want to finish the whole 20 gigs.

The command used is this:

ssh root@rescue-system "dd if=/dev/sda" | dd bs=1M | restic -r repo/ backup --stdin-filename="pathname-to-be-used-in-restic" --stdin

thanks @nicnab great job! i will check that; What command will you do to restore the entire /dev/sda? just to know what exact command will do the restore, and it doesn’t require GRUB update?

Sorry but, as I said, I stopped there. But with the command above, you should be able to find out and test the restore.

I’m guessing that if you have the same machine to restore to, there should be no grub trouble. That’s why I went for the whole /dev/sda device. But maybe there are folks here with more knowledge about these things? And, of course, only a test will bring certainty.

you guess right, and usually i will try it on the Cloud also, VM based.

1 Like

I usually use:

sudo pv -Eq /dev/diskX | restic --stdin --stdin-filename=image.bin

Where -E skips any errors, and -q is quiet (Restic will output how much it’s saved)

To restore is only mildly trickier, as you need Restic to run as root too, in order to overwrite a block device:

sudo sh -c 'restic dump 1a2b3c4d image.bin > /dev/diskX'

But for the record, even this would work to backup, provided there are no errors:

sudo cat /dev/diskX | restic --stdin

If it gets hung up wanting a sudo password, just do:

sudo echo; sudo cat /dev/diskX | restic --stdin

That will prompt for your password, which will cache it for a few minutes, and immediately run cat as sudo.

2 Likes

I don’t go the dd way. My Cloud Servers are doing

restic backup --exclude="/var/cache/*" --exclude="/proc/*" --exclude="/sys/*" --exclude="/tmp/*" --exclude="/var/tmp/*" /

every night and it’s fine for me. If necessary, I stop some daemons (like database servers) before to be sure everything is consistent.

I also tried full restores, which I described here some time ago.

1 Like

That is my way too. All machines are documented so they can be reinstalled at any time so all I need is a backup of the data. Everything else keeps me from sleeping well.

1 Like