User Tools

Site Tools


libvirt:libvirt

This is an old revision of the document!


Table of Contents

Libvirt

Copy a VM

Export

In this example a running VM named 'foobar' is exported:

cd /my/backup/dir/foobar
virsh dumpxml foobar > foobar.xml

In order to copy the virtual harddrive the VM probably needs to be shut down. Otherwise the running state will need a memory dump as well and we don't want that now. So; shut down the VM and run the following command:

# Find location of image:
virsh dumpxml foobar | grep '\.img'

cd /my/backup/dir/foobar
cp /location/of/image/foobar.img .

Import

Now we can import it again. First copy the harddrive image to the correct location and make sure to modify the xml accoringly (if it was moved). Optionally change the name if so desired by modifying the contents of the <name> tag in line 2. Now import the VM:

cd /my/backup/dir/foobar
virsh define foobar.xml
libvirt/libvirt.1407395215.txt.gz · Last modified: 2014/08/07 09:06 by deva