1

I'm running Debian 9.1 with KDE with full disk encryption and would like to do a backup of the entire drive (including the separate /home partition) using rsync in a way that allows me to restore the system at failure.

How can I do that? What do I need to pay attention to for backuping when my hard drive is encrypted?
(For example do I need to have the drive I backup to formatted in a specific way?)

1

You have to define failure. Possible options include

  1. Some partitions (e.g.: /boot or /) have missing/invalid data which prevents the system from booting
  2. Some partitions (e.g.: /boot or /) are corrupted/unmountable
  3. You forgot the encryption password
  4. The entire disk failed
  5. The bootloader is corrupted

The Debian installation media offers useful recovery options.

  • You can provide your password and mount the encrypted partitions which survived failure. From there you can restore the data you backed up with rsync. This is useful to recover from 1.
  • You can re-partition your disk. This includes creating new encrypted partitions, possibly with different passwords. Once this is done you can restore the data you backed up with rsync. You need to make sure the partition table and LVM match the original. This is useful to recover from 2, 3, or 4 after replacing the drive.
  • You can fix the bootloader. If nothing else failed you don't need to restore data.

TL;DR: No specific precautions are required. If you want to rely on rsync alone make sure you can recreate the partitions if you have to, but this is not specific to using encryption. Other options include

  • Backing up the entire disk (not using rsync). This requires more space and time for each backup, but makes it easier and faster to restore. It won't save you if you forget the password.
  • Accepting to reinstall the system and only restore the data (not the programs) in case of issues.
  • Thanks, this is helpful. So if I were to go for a backup of the entire disk to protect against 1,2,3,4 and 5 what would you recommend and are there ways to run such backups as incremental backups? And in addition, how can I make sure that the partition table and LVM match the original? – mYnDstrEAm Aug 22 '17 at 11:02
  • 1
    For partition table dump/restore you can use sfdisk from the util-linux package. For whole-disk non-incremental backup you can use dd. I am not sure how to deal with whole-disk incremental backups and LVM dump/restore. If you backup with dd you don't need to worry about restoring the LVM. As a casual desktop user I only back up my data. It is simple, faster, and requires less storage. However in the event of a crash, it will take me a few hours to restore my system. I would only consider whole-disk backups on a server where I cannot afford a long downtime in the event of a crash. – marcv81 Aug 22 '17 at 11:56
  • I used BackInTime which uses rsync for the backup. And I ran sudo sfdisk -d /dev/sda > part_sda to make a backup of the partition table. I hope that's good enough. – mYnDstrEAm Aug 23 '17 at 17:09
  • 1
    You might also want to write down the results of sudo pvdisplay. They would help to recreate the LVM if required. With a backintime backup you can definitely restore all your data. If you want to be sure that you can also restore the whole system you could test the procedure with a virtual machine. – marcv81 Aug 24 '17 at 2:49
0

rsync is a file-oriented backup solution, it does not depend on the underlying block devices (LVM, RAID, encryption, and so on). You just have to ensure that there is enough disk space at the destination, and that the underlying file system supports all the file attributes (whatever they are: symlinks, hardlinks, devices, Unix permissions, xattr, etc.) of your source. If unsure, the safest is to use the same file-system.

0

Do a backup from filesystem level (using a tool of your choice, rsync, rsnapshot, duplicity etc.) and encrypt it separately (if required).

If you really want to do a block level backup, full disk encryption doesn't add any considerations, restore is a matter of writing the image back to the device.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.