1. 说明

一直在思考一个问题,既然pve都是以虚拟机的形式管理,那我现在创建并配置好一个centos,将镜像源、基础软件、docker、Java等安装好了之后,作为一个模板来储存起来呢,这样以后就不用每次装一个系统都来重头配一遍了,岂不是很好。
然后在网上搜了一下,不出意外的,果然有,那就开始行动吧。

2. 虚拟机备份

  • 点击需要备份的虚拟机
  • 选择备份选项
  • 点击立即备份
    ad1bb926ce799ce42f47d94105896e1f
  • 在备份选项里面的模式选择停止
    3b17d206217ea9d243511a3d5c485e00
  • 执行备份
    51c11eb730d8c2afd1054e2c955da476

我们可以看到输出的路径为/var/lib/vz/dump
然后我们就可以在上一个备份界面看见了当前虚拟机备份列表。
除了在虚拟机的备份列表中可以看到,在虚拟机界面的local卷中也可以看见,如下
a95ce91790e73e1bbf2a9c275101f12e

备份好了就可以使用FTP工具在/var/lib/vz/dump中找到镜像并拷贝到自己的存储中存起来了
486f8f5de5483560a4caa05c0ff3db13

3. 虚拟机还原

在我的使用场景中,当然是只能在lcoal卷中还原,毕竟要全新恢复一个镜像

local卷中,单击备份选项,选中需要还原的备份文件,点击还原
(如果原来拷贝到其他地方去了,则需要将拷贝的文件还原到/var/lib/vz/dump里面,pve才能识别)
然后选择配置参数,这里默认会使用备份时的参数,也可以自己选择一些参数,主要是需要指定虚拟机ID,根据自己的情况配置其他的,然后点击还原
当进度跑满100时,会卡一下,实际后台还没跑完,等到出现了TASK OK时,表示已经完成了,此时已经出现了新的虚拟机了,关闭当前窗口即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
restore vma archive: zstd -q -d -c /var/lib/vz/dump/vzdump-qemu-101-2024_08_02-13_58_08.vma.zst | vma extract -v -r /var/tmp/vzdumptmp66400.fifo - /var/tmp/vzdumptmp66400
CFG: size: 512 name: qemu-server.conf
DEV: dev_id=1 size: 34359738368 devname: drive-scsi0
CTIME: Fri Aug 2 13:58:09 2024
WARNING: You have not turned on protection against thin pools running out of space.
WARNING: Set activation/thin_pool_autoextend_threshold below 100 to trigger automatic extension of thin pools before they get full.
Logical volume "vm-101-disk-0" created.
WARNING: Sum of all thin volume sizes (64.00 GiB) exceeds the size of thin pool pve/data and the amount of free space in volume group (14.75 GiB).
new volume ID is 'local-lvm:vm-101-disk-0'
map 'drive-scsi0' to '/dev/pve/vm-101-disk-0' (write zeros = 0)
progress 1% (read 343605248 bytes, duration 0 sec)
......
progress 98% (read 33672593408 bytes, duration 7 sec)
progress 99% (read 34016198656 bytes, duration 7 sec)
progress 100% (read 34359738368 bytes, duration 7 sec)
total bytes read 34359738368, sparse bytes 30720786432 (89.4%)
space reduction due to 4K zero blocks 2.29%
rescan volumes...
TASK OK