Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Red Hat Enterprise Linux Server Cookbook

You're reading from   Red Hat Enterprise Linux Server Cookbook Over 60 recipes to help you build, configure, and orchestrate RHEL 7 Server to make your everyday administration experience seamless

Arrow left icon
Product type Paperback
Published in Dec 2015
Publisher
ISBN-13 9781784392017
Length 250 pages
Edition 1st Edition
Tools
Concepts
Arrow right icon
Authors (2):
Arrow left icon
Jakub Gaj Jakub Gaj
Author Profile Icon Jakub Gaj
Jakub Gaj
William Leemans William Leemans
Author Profile Icon William Leemans
William Leemans
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Working with KVM Guests FREE CHAPTER 2. Deploying RHEL "En Masse" 3. Configuring Your Network 4. Configuring Your New System 5. Using SELinux 6. Orchestrating with Ansible 7. Puppet Configuration Management 8. Yum and Repositories 9. Securing RHEL 7 10. Monitoring and Performance Tuning Index

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 --pool $i --inactive > /tmp/pool-$i.xml; \
done

Here's the guest configuration:

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

How it works…

The virsh net-dumpxml command allows you to dump the precise configuration of the specified network. In combination with virsh net-list, you can create a loop that enumerates all networks and dumps them on the file. By specifying –-all, you will export all networks, even those that are not active. If you do not wish to back up the configuration for nonactive networks, substitute virsh net-list --all with virsh net-list.

Storage pools can be enumerated, similarly to networks, using virsh net-list. However, besides the individual storage pool configuration, we are also interested in the configuration of individual storage volumes. Luckily, both implement a list and dumpxml command! If you're not interested in nonactive pools, you can omit the --all option with virsh pool-list.

Guests can similarly be enumerated and their XML configuration dumped using dumpxml. Again, if you're not interested in nonactive guests, you can omit the --all option with virsh list.

See also

The man page for virsh (1) lists all the possible options for the commands used in the preceding section.

You have been reading a chapter from
Red Hat Enterprise Linux Server Cookbook
Published in: Dec 2015
Publisher:
ISBN-13: 9781784392017
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime