使用“virsh snapshot-create-as”备份虚拟机一次即可。第二次失败

使用“virsh snapshot-create-as”备份虚拟机一次即可。第二次失败

我正在运行带有 QEMU 4.2.1 的 Ubuntu 20.04,并尝试使用以下说明设置备份: https://libvirt.org/kbase/live_full_disk_backup.html(较旧的 libvirt 指令,因为 Ubuntu 20 有较旧的 libvirt)。

备份方法一次有效,但第二次运行时失败。这可能与使用将 VM 磁盘作为 .raw 文件的 VM 的说明有关,但我使用的是 .qcow2。此时有多个虚拟机,所以我不想转换为 .raw。

当我跑步时:

$ virsh snapshot-create-as --domain vm1 overlay1 \
    --diskspec vda,file=/var/lib/libvirt/images/overlay1.qcow2 \
    --disk-only
virsh blockcommit vm1 vda --active --verbose --pivot 

一切正常,没有错误。如果我不删除“overlay1.qcow2”文件并再次运行该命令,则会收到以下错误:

error: unsupported configuration: external snapshot file for disk vda already exists and is not a block device: /var/lib/libvirt/images/overlay1.qcow2 

如果我在再次运行之前删除该文件(按照说明的建议):

error: operation failed: domain moment overlay1 already exists 

做了一些挖掘并运行了快照列表:

$ virsh snapshot-list --tree vm1
overlay1 

尝试删除快照:

virsh snapshot-delete vm1 overlay1
error: Failed to delete snapshot overlay1
error: unsupported configuration: deletion of 1 external disk snapshots not supported yet

不知道从这里去哪里。
我必须使用 .raw 图像吗? 。 。如果是这样,为什么?

谢谢。

答案1

感谢 Alex 提供了一个链接,告诉我如何删除快照元数据。

使用 .qcow2 映像的 VM 的一系列有效命令是:

$ virsh snapshot-create-as --domain vm1 overlay1 \
    --diskspec vda,file=/var/lib/libvirt/images/overlay1.qcow2 \
    --disk-only
(Insert your backup command here)
$ virsh blockcommit vm1 vda --active --verbose --pivot 
$ virsh snapshot-delete vm1 --metadata overlay1
$ rm -f /var/lib/libvirt/images/overlay1.qcow2

相关内容