I'm trying to setup a KVM backup solution for our servers that would take live backups without stopping the system.

I Found several ready scripts which i have tested, but they all either stop or "freeze" the VM for a little while, to save memory state. But this is no good for us.

We have few custom application that write logs, that need to be consistent and we cannot have 10-60second pauses while system is "freezed" for the duration of backups, also this "freeze" causes the VM's clock to be out of sync ( clock is behind by the duration of the "freeze) which in term messes with our custom sofware, where one of its functions is to monitor some measuring equipments timestamps.

So where question is, is there a way to do full VM backups that can be done consistently without freezing the VM and restore of backup should work aswell :)

here is one of the several scripts i have tried for an example: KVM QCOW2 Live backup

  • 2
    Are you trying to do a backup of filesystems or saving the VM's state? Try to present the problem instead of a solution you don't like. – niglesias Aug 9 '17 at 18:58
  • I guess what im trying to do is save VM's state(?) im not really sure, all i know is that i want a backup that i can use to restore a VM. And the creation of said backup should not stop the software running on the VM that is being backed up, because even a 10second freeze on the VM would break our software. – Nanoni Aug 9 '17 at 21:39

The easiest and most common solution would be to take a live snapshot of the VM (fsfreeze/flush/use the qemu-ga to maintain fs consistency before taking the snapshot), back up the underlying image, while the VM writes to the snapshot, and then merge the two when the backup is complete.

  • This would just create a filesystem backup? not a easily restorable qcow2 backup image? I have a rdiff-backup already doing backups of all files on the system, what i really need is a qcow2 backup i can easily just attach to a new VM and start it up and it should start running. – Nanoni Aug 9 '17 at 21:39
  • 1
    Why would you think so? I explicitly said to back up the image – dyasny Aug 10 '17 at 1:09
  • I have no idea why i thought that, like you said filesystem wasnt mentioned at all, only image was :) Anyways, you wouldnt happen to have and example of the procedure, i think [link] (redhat.com/archives/libvirt-users/2015-September/msg00042.html) is an example of what you said but im not sure, since it says #Blockcommit snapshot back into backing file, shouldnt it be the otherway around? – Nanoni Aug 10 '17 at 4:55
  • 1
    There is plenty of code out there. The general steps I have already described above. I suggest you try to implement it yourself, and if something doesn't work, ask a more specific question on SF. The link you provided does exactly what I was talking about, even including the qemu-guest-agent, I also mentioned above – dyasny Aug 10 '17 at 13:31

I'd go with a different approach: instead of saving the whole VM's state, I'd keep a pristine image of a freshly installed VM just in case, and do routine backups of the data I'm interested to keep safe. The specific techique to do such a backup depends on the tools you are using (MySQL? InfluxDB?).

If you are using LVM for the VM's storage you can also use LVM snapshots, wich are quick and not disruptive. This has the disadventage of not having the VM's RAM into account so it MIGHT have invalid data on any point in time.

  • Hmm... yes, you might be right. I am using LVM and doing data backups using snapshot + rdiff-backup to backup some data now, i guess i could expand that to backup all data, and i already have a pristine clone's of current VM's. Although the chance of having invalid data scares me. Need to think about this a bit more, before i decide what to do. – Nanoni Aug 10 '17 at 11:37
  • This. Your VM should be stateless. And it shouldn't be a VM it should be a container. – Warren P Feb 18 '18 at 0:22

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.