From: http://blog.csdn.net/weiyuanke/article/details/7639742 #
In openstack, Vm instances are generally placed under the Nova/instances directory.
The typical structure of this directory is as follows:
Root @ node77 :~ # Ls/opt/stack/NOVA/instances/
_ Base instance-0000001a
Where
The _ base Directory stores the base image of the VM instance.
The instance-0000001a stores the incremental part of the Virtual Machine instance image.
The instance-0000001a directory has the following files:
Root @ node77 :~ # Ls/opt/stack/NOVA/instances/instance-0000001a/
Console. Log disk. Local libvirt. xml
Where
Console. Log saves the log information of VM startup.
Disk and disk. Local are the image files of the VM instance.
Libvirt. XML is the configuration file.
Note that disk and disk. Local do not contain all the data of the virtual machine. They are only incremental parts based on the base image.
We can view this information through the KVM-image tool, as shown below:
Root @ node77:/opt/stack/NOVA/instances/instance-0000001a # KVM-IMG info Disk
Image: Disk
File Format: qcow2
Virtual size: 50 GB (53687091200 bytes)
Disk size: 1.6 GB
Cluster size: 2097152
Backing file:/opt/stack/NOVA/instances/_ base/5dcb736a3fbb7f5b92657095aa77a877f4039ec0_10 (actual path:/opt/stack/NOVA/instances/_ base/snapshot)
Root @ node77:/opt/stack/NOVA/instances/instance-0000001a # KVM-IMG info disk. Local
Image: disk. Local
File Format: qcow2
Virtual size: 40 GB (42949672960 bytes)
Disk size: 4.0 m
Cluster size: 2097152
Backing file:/opt/stack/NOVA/instances/_ base/ephemeral_0_40_none (actual path:/opt/stack/NOVA/instances/_ base/ephemeral_0_40_none)
The backing file is the base image.
Therefore, when backing up a virtual machine instance, we not only need to back up the data under the instance-0000001a directory, but also to back up the virtual machine-related base image data, that is, the file given by the backing file.
For this example:
We need to back up the following files:
(1) console. Log
(2) disk
(3) disk. Local
(4) libvirt. xml
(5)/opt/stack/NOVA/instances/_ base/ephemeral_0_40_none
(6)/opt/stack/NOVA/instances/_ base/5dcb736a3fbb7f5b92657095aa77a877f4039ec0_10
How to recover the VM on another machine based on the backup file:
Method 1:
We merge the disk and disk. Local disk files with their base image respectively to generate two new disk files. The two disk files will contain all the data of the virtual machine.
qemu-img convert [-c] [-f format] [-o options] [-O output_format] filename output_filename
qemu-img convert disk –O qcow2 newdisk
qemu-img convert disk.local –O qcow2 newdisk.local
Method 2:
Modify the location of the backing file in the disk and disk. Local files to the location of the current base image.
qemu-img rebase [-f format] [-u] -b backing_file [-F backing_format] filename
After the disk files are correctly processed, the rest of the work is to start the virtual machine according to the libvirt. xml file settings.
There are many documents on the Internet for reference.