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
  • 6
  • 1
    Correct me if I'm wrong, but reverting to LVM snapshots is possible for 10 years or so? – Gerald Schneider Nov 13 '20 at 12:39
  • 2
    Does this answer your question? [Commit or revert a Linux LVM snapshot?](https://serverfault.com/questions/128878/commit-or-revert-a-linux-lvm-snapshot) – Gerald Schneider Nov 13 '20 at 12:47
  • I believe you if you tell me that you use this, I just don't know how(!) :-). Reviewing your link, I'm not sure I understand it. Could you tell me the broad steps please? i.e. 1. What packages do I need to install? 2. Does this involve partitions (i.e. do I need to allocate space somewhere equal in size to my main partition to hold this information? or is it in a sense just storing snapshot difference information?) 3. Is it just as simple as "run a command, reboot, and hey presto, I have rolled back to Snapshot 0 or Snapshot 1" etc? – YorSubs Nov 13 '20 at 13:01
  • 1
    I'm going through some guides on LVM now, and it seems *horrifically* convoluted and complex to set this up. Seemingly it involves massively altering the partitions on the computer. Maybe I'm wrong, but spending 2 or 3 hours just to get to a starting point and then having to have deep knowledge of LVM complexity is incredibly different from making an in-place snapshot (or multiple snapshots) that we can roll back to. I don't mind complexity, but this seems a far cry from the ease and efficiency of Macrium Reflect (!!). Doesn't CentOS have something *"less massively complex"*? – YorSubs Nov 13 '20 at 13:06
  • I could be wrong though. Are LVM's something that you can setup in 10 minutes and be easily creating Snapshots that you can rollback to with ease? It sounds like you have experience with this, if you tell me this is easy to work with I will investigate further, but on reviewing a number of pages, this does look really complex stuff? – YorSubs Nov 13 '20 at 13:15
  • When you create a an LVM snapshot, you have to give it enough space to hold the differences from the original. Only blocks with differences will occupy space. Once you get used to it, LVM is much more flexible than partitions. It seems more complex because it does a lot more: move, copy, RAID, etc. If you have one disk, you will have one PV on one big partition, one VG and a bunch of LVs. Make the LVs big enough but leave lots of free space, it is easy to increase them later. – stark Nov 13 '20 at 15:26
  • I do use such technologies in my work on EMC Enterprise Storage VMAX etc, but these are all unbelievably complex solutions for home use. My needs, like most home users, are not absolute Enterprise resiliency (at home, that is). I just want to get a CentOS setup, mess it up, try out things, break things, but then be able to go back to my well-defined-known-snapshot/backup after doing my experiments and learning. i.e.a "reset" button, and hopefully (surely?) Linux should empower us to do something that is so easy to do in Windows? :-( – YorSubs Nov 13 '20 at 15:35

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
  • 1
  • 8
  • 1
    Thanks for this Abbas, I will definitely try this out at some point, but incidentally, I did also find another solution that seems to be exactly what I was looking for. Still not had a chance to test it, but TimeShift seems to do everything that I was wanting utilising `rsync` or `btrfs` and can do live rollbacks of the entire OS (leaving userfiles untouched i.e. no more USB sticks when want to perform a rollback on a remote system! It can also do full system restores if the OS is broken and non-booting by booting from a USB if required though). – YorSubs Nov 17 '20 at 13:42
  • 1
    TimeShift also seems to completely support small headless Linux server setups which OI like, though I've yet to find good documentation for the console - most articles only covers the GUI. http://www.linuxandubuntu.com/home/timeshift-a-system-restore-utility-tool-review – YorSubs Nov 18 '20 at 07:11