====== 08 qcow2 バックアップ 外部へ取得する場合(online external) ======
内部スナップショットは、[[01_linux:08_仮想化:kvm:10_qcow2_backup_internal]]
===== ディスク確認 =====
root@hvdev1001:~# virsh domblklist testvm
Target Source
------------------------------------------------
vda /var/lib/libvirt/images/testvm.qcow2
sda -
===== スナップショット作成 =====
root@hvdev1001:~# virsh snapshot-create-as testvm --name testsnap --no-metadata --disk-only
Domain snapshot testsnap created
==== スナップショット作成後 ====
root@hvdev1001:~# virsh domblklist testvm
Target Source
---------------------------------------------------
vda /var/lib/libvirt/images/testvm.testsnap
sda -
# virsh dumpxml testvm
.
.
.
.
.
===== スナップショット後は、元ファルがバックアップできる =====
# qemu-img info /var/lib/libvirt/images/testvm.qcow2
image: /var/lib/libvirt/images/testvm.qcow2
file format: qcow2
virtual size: 25 GiB (26843545600 bytes)
disk size: 4.16 GiB
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: true
refcount bits: 16
corrupt: false
# cp /var/lib/libvirt/images/testvm.qcow2 /backups/
==== 圧縮するとサイズが小さくなる ====
容量の節約には圧縮しとく方法もある。
※コンバートには時間がかかります。
# qemu-img convert -c -f qcow2 -O qcow2 /var/lib/libvirt/images/testvm.qcow2 /backups/testvm.qcow2.bk
# qemu-img info /var/lib/libvirt/images/testvm.qcow2
image: testvm.qcow2
file format: qcow2
virtual size: 100 GiB (107374182400 bytes)
disk size: 12.9 GiB
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: true
refcount bits: 16
corrupt: false
# qemu-img info /backups/testvm.qcow2.bk
image: testvm.qcow2.bk
file format: qcow2
virtual size: 100 GiB (107374182400 bytes)
disk size: 6.88 GiB
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false
# ll -h /backups/testvm.qcow2.bk
-rw-r--r-- 1 root root 6.9G Apr 28 07:55 /backups/testvm.qcow2.bk
===== バックアップ後は、元ファイルへマージ =====
※注意 --base --topはフルパスじゃないとエラーになります。
root@hvdev1001:~# virsh blockcommit testvm vda --base /var/lib/libvirt/images/testvm.qcow2 --top /var/lib/libvirt/images/testvm.testsnap --wait --verbose --pivot
Block commit: [100 %]
Successfully pivoted
root@hvdev1001:~# virsh domblklist testvm
Target Source
------------------------------------------------
vda /var/lib/libvirt/images/testvm.qcow2
sda -
# virsh dumpxml testvm
.
.
.
{{tag>kvm qcow2}}