2

Are there any backup/cloning/recovery tools that can pull files from LUKS-encrypted disks while dropping free blocks?

Something that runs from within the unlocked system and hot-transfers the files, or maybe runs from a bootable USB flash drive, prompts the encryption key, and unlocks the disk?

8
  • Could you expand on what you mean by "dropping free blocks". Commented Jul 20, 2020 at 22:20
  • Hi, I mean leaving out unused space by being file system-aware and copying file by file (what cp does), rather than bit by bit (what dd does) Commented Jul 21, 2020 at 11:11
  • Example: 500 GB disk, 10 GB data. Copy only files => 10 GB backup. Clone bit by bit => 500 GB backup with 490 GB wasted space Commented Jul 21, 2020 at 11:12
  • Is it, for instance, possible to write a Bash script that somehow uses LUKS, prompts for the encryption key, decrypts the disk, then (ideally hot-)transfers all files to a backup drive, and encrypts the backup? Imagine - having a small script like this would be enormously handy. And if the partition structure is reproduced, the backup would even be bootable, i.e. you could just snapshot your entire system onto an external SSD, take it somewhere, and work from it on any host computer. You could carry around your entire (encrypted) workstation! Commented Jul 21, 2020 at 11:17
  • I'd recommend learning how to use rsync to copy files. The fact that your disk is encrypted is largely irrelevant. Whatever you use will need it to be opened (cryptsetup luksOpen ...) before operation. Then all you're really asking for is a backup tool which operates on a file system rather than the block device. Thus I'd suggest rsync as a command line tool which is well designed for copying file trees. Commented Jul 21, 2020 at 11:25

1 Answer 1

1

The fact that your disk is encrypted is largely irrelevant. Whatever you use will need the encrypted disk to be opened (cryptsetup luksOpen ...) before operation.

I'll also draw your attention to e2image which may copy more filesystem meta data. It only works with ext2,3,4 file systems.

Besides e2image, your only real option is to look at tools which copy file trees rather than blocks. For backups, I use rsync copy files.

Besides files, what else does your system need?

Partition definitions will not be backed up with rsync. Partitions sizes can be listed with with fdisk -l <disk> eg: fdisk -l /dev/sda and stored this in a file somewhere for safe keeping.

To boot up, you system will probably use UUIDs to know what file system mount's where. These can be listed with blkid (sudo blkid).

If your system is using EFI (rather than legacy boot) then you need to also copy the contents of your EFI partition.

1
  • Many thanks, I feel like getting much closer to the solution! rsync seems perfect, since it can be used to update the backup or send it to a remote server. Does it fully support hot transfer, i.e. if I do rsync from within the running system, can I be sure that it will copy all files or potentially miss certain ones? And how do you restore your backup, especially everything outside the file system? Commented Jul 21, 2020 at 17:01

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.