CentOS, revert back to a clean state (by backup or snapshot) without physically going to the server [closed]

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