Skip to main content
Topic: What's the correct way to backup LVM fully encrypted system? (Read 578 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

What's the correct way to backup LVM fully encrypted system?

I want to at least back up my system once I am done configuring it in a way that I could restore it in case of a bad update or if I want to reinstall it fresh after some time.

Best would be however if I could back up the system on each boot up or something similar (assuming it doesn't increase the boot time significantly)

I will be using full encryption including /boot using LVM. On arch wiki I saw a guide for that but it said one requirement is systemd which is obviously the reason I will be using artix.

PS. Appreciate it even more if you can give a small example if it's cmd, I'm a linux beginner-moderate and willing and wanting to learn but also wanting to set up my new system before next week and having a job and a family. :)

Re: What's the correct way to backup LVM fully encrypted system?

Reply #1
This solution is very simple and requires space ( probably using something like a separate hard drive to store the backup ), but it doesn't require you to jump through hoops to keep your backup in one piece, learn complex tools or maintain it's structure:
take an entire image of your storage device using dd(1) and compress it using gzip

Before you do any installation, fill your storage device with zeroes from begging to end ( dd if=/dev/zero of=/dev/sdx ), this will help a lot with the compression being more effective. ( filling it with zeroes will also wipe it completely, so get all your data off it )

After the installation and when everything is setup and you want to do backup, run this ( /dev/sdx is your storage device ):
Code: [Select]
dd if=/dev/sdx status=progress bs=512 | gzip - > /mnt/hdd/backup.img.gz

And of course whenever you want roll back your system to that backup, run this:
Code: [Select]
dd if=/mnt/hdd/backup.img.gz of=/dev/sdx status=progress bs=512

The path and file names mentioned here are only for illustration, you have to figure them out on your own system.

Re: What's the correct way to backup LVM fully encrypted system?

Reply #2
you can also use timeshift :)
it can be used in GUI, or in a tty, faully backup your system, lvm or not, encrypted or not (and more if you want), can completely restore it, even with the bootloader.
i used it many times to make a regular backup. a few times i borked my system, and no worries. i restored using timeshift.

Re: What's the correct way to backup LVM fully encrypted system?

Reply #3
This solution is very simple and requires space ( probably using something like a separate hard drive to store the backup ), but it doesn't require you to jump through hoops to keep your backup in one piece, learn complex tools or maintain it's structure:
take an entire image of your storage device using dd(1) and compress it using gzip

Before you do any installation, fill your storage device with zeroes from begging to end ( dd if=/dev/zero of=/dev/sdx ), this will help a lot with the compression being more effective. ( filling it with zeroes will also wipe it completely, so get all your data off it )

After the installation and when everything is setup and you want to do backup, run this ( /dev/sdx is your storage device ):
Code: [Select]
dd if=/dev/sdx status=progress bs=512 | gzip - > /mnt/hdd/backup.img.gz

And of course whenever you want roll back your system to that backup, run this:
Code: [Select]
dd if=/mnt/hdd/backup.img.gz of=/dev/sdx status=progress bs=512

The path and file names mentioned here are only for illustration, you have to figure them out on your own system.

That is OK assuming your target is compatible as it is a ***disk image***.

rsync is pretty straight forward

man rsync

Re: What's the correct way to backup LVM fully encrypted system?

Reply #4
>That is OK assuming your target is compatible as it is a ***disk image***.

So it you mean it doesn't work for stuff like RAID?

Re: What's the correct way to backup LVM fully encrypted system?

Reply #5
>That is OK assuming your target is compatible as it is a ***disk image***.

So it you mean it doesn't work for stuff like RAID?


That is not what I mean but
probably not and it depends on the raid.  When you dd a cd rom or a thumb drive, it is a small standardized device that you are installing on an exactly duplicate physical device or one that is smaller in the case of a thumb drive.  You wipe out the drive on the reinstall and the geometry is exactly duplicated from the old target to the new target (uncluding the MBR/EFI and partitioning schemes btw).  So the target has to be of the right type and adequate size.  With CDs or DVDs, it is easy as they are all the same.  Harddrives in workstations are not.  LVMs give you a bit more flexibilty but it is still the same problem.  It is better to not make any assumptions about the hardware and just backup the files (like with rsync).

Also, be aware that tar files are limited in size and whole systems are often larger than their capacity, something I discovered the hard way.