The KVM virtual machine defaults to the RAW format image format, the best performance, the fastest, its disadvantage is not support some new features, such as support image, zlib disk compression, AES encryption and so on.
To use the mirroring feature, the disk format must be qcow2. The following begins the process of a KVM virtual machine snapshot backup.
This article originates from: http://koumm.blog.51cto.com
Further study reference: Kvm+libvirt virtual machine Snapshot Analysis http://itxx.sinaapp.com/blog/content/130
1. View existing disk image formats and conversions
(1) View disk format
# qemu-img Info test01.img
Raw format needs to be converted into Qcow2
(2) Turn off the virtual machine and convert the disk
# Virsh Shutdown oeltest01
(3) Convert disk format
# qemu-img convert-f raw-o qcow2 test01.img test01.qcow2
The format of the-F source image
-o The format of the target image
View the converted format, has been converted to Qcow2, here is a copy, and convert the format to Qcow2
# qemu-img Info Test01.qcow2
2. Modify the virtual machine configuration file
Modify the disk format, with the new qcow2 format of the disk.
3. Snapshot management of virtual machines
(1) Create a snapshot of the oeltest01 virtual machine
You can also Virsh snapshot-create as oeltest01 snap1 after creating a snapshot alias.
(2) View the version of the virtual machine image snapshot
(3) View the version of the current virtual machine image snapshot
You can see the latest snapshot version for the current.
[Email protected] data]#
[Email protected] data]# Virsh snapshot-current oeltest01
<domainsnapshot>
<name>1378579737</name>
<state>shutoff</state>
<creationTime>1378579737</creationTime>
<memory snapshot= ' no '/>
<disks>
<disk name= ' hda ' snapshot= ' internal '/>
<disk name= ' hdc ' snapshot= ' no '/>
</disks>
<domain type= ' KVM ' >
<name>oeltest01</name>
<uuid>8f2bb4a7-c7ed-32aa-3676-9fb05923269d</uuid>
<memory unit= ' KiB ' >524288</memory>
<currentmemory unit= ' KiB ' >524288</currentMemory>
<vcpu placement= ' static ' >1</vcpu>
<os>
<type arch= ' x86_64 ' machine= ' rhel6.4.0 ' >hvm</type>
<boot dev= ' HD '/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset= ' localtime '/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type= ' file ' device= ' disk ' >
<driver name= ' qemu ' type= ' qcow2 ' cache= ' None '/>
<source file= '/data/test01.qcow2 '/>
<target dev= ' hda ' bus= ' ide '/>
<address type= ' drive ' controller= ' 0 ' bus= ' 0 ' target= ' 0 ' unit= ' 0 '/>
</disk>
<disk type= ' block ' device= ' cdrom ' >
<driver name= ' qemu ' type= ' raw '/>
<target dev= ' hdc ' bus= ' IDE '/>
<readonly/>
<address type= ' drive ' controller= ' 0 ' bus= ' 1 ' target= ' 0 ' unit= ' 0 '/>
</disk>
<controller type= ' IDE ' index= ' 0 ' >
<address type= ' PCI ' domain= ' 0x0000 ' bus= ' 0x00 ' slot= ' 0x01 ' function= ' 0x1 '/>
</controller>
<controller type= ' usb ' index= ' 0 '/>
<interface type= ' bridge ' >
<mac address= ' 52:54:00:82:39:01 '/>
<source bridge= ' br0 '/>
<model type= ' Virtio '/>
<address type= ' PCI ' domain= ' 0x0000 ' bus= ' 0x00 ' slot= ' 0x03 ' function= ' 0x0 '/>
</interface>
<serial type= ' pty ' >
<target port= ' 0 '/>
</serial>
<console type= ' pty ' >
<target type= ' serial ' port= ' 0 '/>
</console>
<input type= ' tablet ' bus= ' USB '/>
<input type= ' mouse ' bus= ' ps2 '/>
<graphics type= ' vnc ' port= ' 5910 ' autoport= ' no ' listen= ' 0.0.0.0 ' >
<listen type= ' address ' address= ' 0.0.0.0 '/>
</graphics>
<video>
<model type= ' Cirrus ' vram= ' 9216 ' heads= ' 1 '/>
<address type= ' PCI ' domain= ' 0x0000 ' bus= ' 0x00 ' slot= ' 0x02 ' function= ' 0x0 '/>
</video>
<memballoon model= ' Virtio ' >
<address type= ' PCI ' domain= ' 0x0000 ' bus= ' 0x00 ' slot= ' 0x04 ' function= ' 0x0 '/>
</memballoon>
</devices>
</domain>
</domainsnapshot>
[Email protected] data]#
(4) View the current virtual machine image file
Another one is created, and the version of the snapshot is also recorded in the image file.
Snapshot profile on/var/lib/libvirt/qemu/snapshot/virtual machine name/Bottom
4. Recovering a virtual machine snapshot
(1) Restoring a virtual machine snapshot must shut down the virtual machine.
Confirm that the virtual machine is powered off
(2) Confirm the need to recover the snapshot time, here to restore to 1378579737
(3) Perform the recovery and confirm the recovery version
# Virsh Snapshot-revert oeltest01 1378579737
5. Deleting a virtual machine snapshot
(1) Viewing virtual machine snapshots
# qemu-img Info Test01.qcow2
Delete the first snapshot here 1378579737
(2) Deleting a snapshot
To this KVM virtual machine snapshot test is complete. KVM Virtualization Learning notes are here, and it feels like there's a lot of KVM virtualization content. The water is getting darker and deeper.
kvm--Virtual Machine Snapshot backup