サイドバー

このページの翻訳:



最近の更新



Tag Cloud

01_linux:08_仮想化:kvm:08_qcow2_online_external_backup

08 qcow2 バックアップ 外部へ取得する場合(online external)

ディスク確認

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
.
.
.
    <disk type=&#039;file&#039; device=&#039;disk&#039;>
      <driver name=&#039;qemu&#039; type=&#039;qcow2&#039;/>
      <source file=&#039;/var/lib/libvirt/images/testvm.testsnap&#039; index=&#039;3&#039;/>
      <backingStore type=&#039;file&#039; index=&#039;2&#039;>
        <format type=&#039;qcow2&#039;/>
        <source file=&#039;/var/lib/libvirt/images/testvm.qcow2&#039;/>
        <backingStore/>
      </backingStore>
      <target dev=&#039;vda&#039; bus=&#039;virtio&#039;/>
      <alias name=&#039;virtio-disk0&#039;/>
      <address type=&#039;pci&#039; domain=&#039;0x0000&#039; bus=&#039;0x03&#039; slot=&#039;0x00&#039; function=&#039;0x0&#039;/>
    </disk>
.
.

スナップショット後は、元ファルがバックアップできる

# 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
.
.
.
    <disk type=&#039;file&#039; device=&#039;disk&#039;>
      <driver name=&#039;qemu&#039; type=&#039;qcow2&#039;/>
      <source file=&#039;/var/lib/libvirt/images/testvm.qcow2&#039; index=&#039;2&#039;/>
      <backingStore/>
      <target dev=&#039;vda&#039; bus=&#039;virtio&#039;/>
      <alias name=&#039;virtio-disk0&#039;/>
      <address type=&#039;pci&#039; domain=&#039;0x0000&#039; bus=&#039;0x03&#039; slot=&#039;0x00&#039; function=&#039;0x0&#039;/>
    </disk>
01_linux/08_仮想化/kvm/08_qcow2_online_external_backup.txt · 最終更新: 2023/04/28 08:17 by matsui