1

I am running CentOS 8 and I would like to rollback to a point in time (backup or snapshot), but without having to boot from USB. Many tools permit this on Windows (e.g. Macrium Reflect) and I would very much like similar on Linux.

Why this is important/useful: I have one CentOS system in my loft and one that is remote (at my parents). These are not high end Enterprise solutions, but I would like to be able to restore them without having to go to them with a USB stick.

Please note: this question is not related to VM's; I use VM's often at work and home, but this question is about managing bare metal installations. LVM's were mentioned in answers, but these are highly intrusive involving huge alteration to partition structure and extremely complex Enterprise Server Management (I have no doubt that LVM's are excellent technology for mission critical Enterprise environments however).

For example, I would like to be able to do the following scenario, and do all of this remotely from the systems (no USB stick required for the Backup or the Restore):

• Install a clean version of CentOS 8 on bare metal.

• Install some tool, then using that tool take a snapshot/backup of the current OS state (say "Snapshot 0" or "Backup 0").

• Make a bunch of changes and make a new snapshot (say "Snapshot 1" or "Backup 0").

Then, I can instruct my system to rollback to "Backup 0" or "Backup 1". It goes ahead and reboots itself into a restore state, performs the restore and then reboots back into CentOS. A reboot would be required of course, but not having to physically go to the remote server with a USB stick or other old-fashioned cumbersome means of achieving this is the point - and the thing is, this is all so completely straightforward and easy to do on Windows with tools like Macrium Reflect that I'm hoping someone can let me know that an OS like CentOS has "2020 capabilities" and not stuck to the bad old days of having to use a USB stick to have to rollback with etc (CentOS is great, and so I'd really appreciate knowing how to do this)?

So, can we take bare metal snapshots/backups of a running Linux server, then rollback to those restore points, without having to USB boot, just like Macrium Reflect or various other software on Windows can do so easily on Windows?

YorSubs
  • 135
  • 1
  • 7

1 Answers1

1

No, it's not horribly convoluted and complex to create a snapshot of your filesystem and restore it in CentOS. However, it's also not the easiest thing in the world.

The trick is to understand the idea of logical volumes, once you do, it's a matter a running a few commands to create a snapshot of, let's say, your root partition. Restoring a snapshot is 2 commands at most.

Here's a rudimentary primer on the idea of volume management:

Logical volumes (LV) sit between physical storage and the file systems. Given your filesystem is on LV1, you can create a second logical volume, LV2, and take a snapshot of your entire filesystem on LV2. Restoring the snapshot would just be a matter of getting the contents of LV2 back to your filesystem.

For a more concrete example, assume that:

  • You have 2 disks (Physical Volumes or PVs) - sda and sdb
  • Your root (/) filesystem is on sda while sdb has nothing on it
  • Your logical volumes are grouped in a volume group called myvolgrp
  • Your root filesystem is on a logical volume called myvolgrp-root (you can see this under /dev/mapper)
  • You have switched to root

# Extend current volume group to unused disk: sdb

vgextend myvolgrp /dev/sdb

# Create logical volume called snapshot1_root, assuming 4 GB is the size of sdb and that 4 GB is enough for your purposes

lvcreate --size 4 GB --name snapshot1_root --snapshot /dev/mapper/myvolgrp-root

# Restore root fs on original LV

lvconvert --mergesnapshot myvolgrp/snapshot1_root

reboot

Abbas
  • 190