What's the fastest method to backup and restore a luks encrypted device (e.g. a full encrypted usb-device to a image-file).
The usb-device can be decrypted/accessed. I'm looking for a solution to mount the backup image as a file (encryped). Can it be possible?
Keep it simple, stupid.
Best Answer
cryptsetup
handles image files just as well as block devices, if that was your question. So if you make add
image (which will be freaking huge) it will work. And if it didn't, you could just create the loop device yourself.Best practice (if you want to keep the backup encrypted) is to encrypt the backup disk also, then open both containers, then run any backup solution of your choice as you would with unencrypted filesystems. It won't be the fastest method as it'd decrypt data from the source disk and then re-encrypt it for the backup disk. On the other hand it allows for incremental backup solutions, so it should still beat the dd-image-creation on average.
If you want to stick to
dd
, the only way to make something faster thandd
would be apartimage
of sorts which takes LUKS header and offset into account, so it would only store the encrypted data that is actually in use by the filesystem.If the source disk is a SSD and you allow TRIM inside LUKS, and the SSD shows trimmed regions as zeroes, you get this behaviour for free with
dd conv=sparse
. It's still not something I'd recommend, though.