Backup and Restore KVM Vms

Photos via Pexels

Introduction

Backup your KVM VM

sudo su
virsh list --all
virsh shutdown vm_name
virsh list --all
virsh dumpxml vm_name
virsh domblklist vm_name
/var/lib/libvirt/images/
virsh dumpxml vm_name > /opt/kvm_backup/vm_name.xml
cp /var/lib/libvirt/images/xxxx.qcow2 /opt/kvm_backup

Restore your KVM VM

virsh undefine vm_name
virsh list --all
cd /var/lib/libvirt/images
rm -rf xxxx.qcow2
cp /opt/kvm_backup/wxxx.qcow2 /var/lib/libvirt/images/
virsh define --file  /opt/kvm_backup/vm_name.xml
virsh list --all
virsh start vm_name

References

A Tech Writer, passionate about Network and Systems with a high interest in Cloud,Virtualization and Machine Learning.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store