0

Over the past month I've been putting my mind into how LVM works. The initial thought was that it is very flexible, I was surprised the system could still run while moving the disk to another local disk.


I couldn't find much info in this online, but it seem like a thing that should be possible to do. Maybe it's not practical, or generally not a good solution (?). The articles I read, were all surrounding local disks, not external.

When I say backup, I mean the whole disk/partition, not snapshot.

Let's say I have 4 servers all running LVM, and I would like to backup all the disks to a big storage server, is that possible?

If it is possible, what would be the cons with such a configuration?

2 Answers 2

2

Yes.

Tthis is used widely, and it actually involves snapshots to ensure consistency of the backup.

For example, this is the way virtual machine (and container) storages are backed up in the Proxmox VE:

  • Suspend the VM. There is no way to atomically make several snapshots in Linux, so the only way to back up all disks at the very same moment of time is to make sure VM can't do anything until all snapshots are ready
  • Snapshot all disks. This process is relatively fast
  • Unsuspend the VM. The time while VM was unavailable is small, up to the point it is not noticeable
  • Send images of all snapshots to the backup storage. This is the long process. But the fact these are snapshots enables us to have consistent backup, while VM could still run. The state of the backup will be the moment when VM was first suspended
  • Remove all snapshots.

This was the simplified description; actually PVE uses also some tricks in the Qemu to emulate snapshots on the backing storage where there is no such feature, but this is not relevant to the question.

Pros are already described. Cons I can think of are the need to have some spare space in the VG to store these snapshots, and the amount of the space is not possible to predict in general, it depends on the amount of I/O the VM is doing while data is sent to the storage, which in turn depends on the I/O rate, virtual disk size and network capacity. In practice, I never had any problems with this.

I described the particular use case, but whatever you backup, the details of the process will be the same.

0

Backup of fulls to a separate remote storage is not easy with Linux LVM alone. More realistic is LVM snapshots copied somewhere else via some other backup agent.

Let's assume the restore design calls for a block level full copy, independent of the original volume group or its member physical volumes. Snapshots are easy to do, but depend on the source VG and do not meet that requirement. LVM can mirror and split volumes, but the procedure would be more involved.

While these features enable use cases like migrations of primary storage, they are relatively advanced, with fewer examples. Further, it may be tricky to present backup block devices to the host being backed up.

As extra block layer features, LVM itself does not provide access to remote storage. Sure, with a suitable SAN you can access a shared storage array, via fiber channel or iSCSI. These LUNs can be used as LVM PVs. Operationally challenging to do so, as many use cases don't use such SANs, operating system install on local storage, for example. And such SANs tend to be short distance and intolerant of loss. Inserting a mirror into protection storage for everything could make for extreme performance demands to keep up with writes to the primary.

More common is copying snapshots with some other tool. Snapshot the source LV. Create VGs and LVs on the separate protection storage. Either do a block based backup like with dd over ssh, or mount the snapshot and do file based backups. Delete the snapshot LV.

2
  • dd over ssh seems like a relatively nice and easy thing to set up, but wouldn't this require partition to not be active? Is it possible to do dd while the system is running and still have the chance to restore it?
    – Typewar
    Aug 31, 2021 at 0:48
  • LVM snapshots are point in time block level copies that do not change as writes continue to the source LV. Consistent point in time backup is a use case. They may be taken online. Aug 31, 2021 at 1:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .