Backing up your VM metadata

While a KVM stores some of the resources' configuration on the disk in a human readable format, it is a good idea to query libvirt for the configuration of your resources.

How to do it…

In this recipe we'll back up all relevant KVM metadata by performing the following steps:

Here's the network configuration:

~]# for i in $(virsh net-list --all | sed -e '1,2d' |awk '{print $1}'); do \
    virsh net-dumpxml --network $i --inactive > /tmp/net-$i.xml; \
done

Here's the storage configuration:

~]# for i in $(virsh pool-list --all | sed -e '1,2d' |awk '{print $1}'); do \
    for j in $(virsh vol-list --pool $i |sed -e '1,2d') | awk '{print $1}'; do \
        virsh vol-dumpxml --pool $i --vol $j > /tmp/vol-$j.xml; \
    done \
 virsh pool-dumpxml ...

Get Red Hat Enterprise Linux Server Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.