How to backup KVM images? Is it possible to backup whole VM?

5,906

I've created a script to fully backup KVM VM's, It doesn't support Live disk backup - but I see it matches your third case Freeze --> backup --> unfreeze

Can backup & restore the VM with its all disks & snapshots

The way it works:

  • suspend the VM if needed
  • backup the VM
  • resume the VM

Example

  • Backup
ruby /root/virt-backup/virt-backup.rb \
  --backup \
  --original-vm snap23 \
  --save-dir /var/lib/libvirt/images/backup-11/ \
  --with-snapshots

  • Restore
ruby /root/virt-backup/virt-backup.rb \
  --restore \
  --with-snapshots \
  --backup-file /var/lib/libvirt/images/backup-11/snap23.zip 
  --restore-dir /var/lib/libvirt/images

Imgur

  • You can find the script with full examples here

https://github.com/eslam-gomaa/virt-backup

Share:
5,906

Related videos on Youtube

MIrra
Author by

MIrra

Updated on September 18, 2022

Comments

  • MIrra
    MIrra over 1 year

    I need to backup all (9 VMs) my KVM VMs. I would like to backup them in the night for example once a week. For example VMware server and VMware server 2 used to have possibility to create live backups using creating images with backups.

    Let me give you a following questions:

    1) Is there any good possibility how to live migrate and backup virtual machines on KVM? I found some tutorials, but they were not working with debian squeeze.

    2) Could you recommend live backup (at night) of KVM VM, or should I rather backup INSIDE of VMs ?

    3) VMware can also do Image backup, when VM is freezed, backed up and UNfreezed back again to work properly. Is it possible to do something like that with KVM VM?

    Thank you for answers and opinions

    • gertvdijk
      gertvdijk over 11 years
      What storage backend are you using? In case you're using Qcow2 images or LVM you can take live snapshots. This could help you out for most cases. If you're using a SAN/NAS, this may give you even more options. Also, share more about the type of applications you're running. A database server (e.g. MySQL) has different requirements regarding data consistency compared to web server.
    • MIrra
      MIrra over 11 years
      I use default...which is Qcow2 i think... I don't use LVM. KVM is working on Software RAID 5 on 7200RPM SATA2 RAID edition disks with 500GB per disk = 1000GB size of RAID 5 array. I don't use NAS/SAN. I don't have MySQL server there, only webservers and some application servers. Because of degraded performance I use MySQL only on main OS not under KVM VM. The question is - CONSISTENCY. If I make snapshots with QCOW2, what about CONSISTENCY? How may I test that image/snapshot for consistency?