我定期为30个虚拟机(VM)拍摄ZFS快照,以进行20次版本控制。
我的快照列表仅适用于两个VM:
rpool/data/vm-100-disk-1@rep_100_2018-08-14_20:08:20 218M - 80.6G -
rpool/data/vm-100-disk-1@rep_100_2018-08-15_00:13:27 46.4M - 80.6G -
rpool/data/vm-100-disk-1@rep_100_2018-08-15_04:23:47 20.6M - 80.6G -
rpool/data/vm-100-disk-1@rep_100_2018-08-15_08:11:11 53.3M - 80.6G -
rpool/data/vm-100-disk-1@rep_100_2018-08-15_11:12:03 181M - 80.6G -
rpool/data/vm-100-disk-1@rep_100_2018-08-15_14:12:32 176M - 80.6G -
rpool/data/vm-100-disk-1@rep_100_2018-08-15_17:12:09 126M - 80.5G -
rpool/data/vm-100-disk-1@rep_100_2018-08-15_20:11:06 120M - 80.5G -
rpool/data/vm-100-disk-1@rep_100_2018-08-16_05:29:05 157M - 80.6G -
rpool/data/vm-100-disk-1@rep_100_2018-08-16_11:27:24 6.72M - 80.6G -
rpool/data/vm-100-disk-1@rep_100_2018-08-16_11:28:08 6.75M - 80.6G -
rpool/data/vm-100-disk-1@rep_100_2018-08-16_14:07:33 208M - 80.5G -
rpool/data/vm-100-disk-1@rep_100_2018-08-16_17:08:18 142M - 80.4G -
rpool/data/vm-100-disk-1@rep_100_2018-08-16_20:05:09 55.3M - 80.4G -
rpool/data/vm-100-disk-1@rep_100_2018-08-17_00:08:29 53.7M - 80.4G -
rpool/data/vm-100-disk-1@rep_100_2018-08-17_04:07:15 46.3M - 80.4G -
rpool/data/vm-100-disk-1@rep_100_2018-08-17_08:06:04 53.9M - 80.4G -
rpool/data/vm-100-disk-1@rep_100_2018-08-17_11:05:05 209M - 80.3G -
rpool/data/vm-100-disk-1@rep_100_2018-08-17_14:15:43 202M - 80.3G -
rpool/data/vm-100-disk-1@rep_100_2018-08-17_17:20:43 0B - 80.2G -
rpool/data/vm-102-disk-1@rep_102_2018-08-14_20:06:09 588M - 75.5G -
rpool/data/vm-102-disk-1@rep_102_2018-08-15_00:06:33 106M - 75.6G -
rpool/data/vm-102-disk-1@rep_102_2018-08-15_04:11:10 65.2M - 75.6G -
rpool/data/vm-102-disk-1@rep_102_2018-08-15_08:06:22 60.6M - 75.6G -
rpool/data/vm-102-disk-1@rep_102_2018-08-15_11:07:57 56.8M - 75.6G -
rpool/data/vm-102-disk-1@rep_102_2018-08-15_14:08:06 58.4M - 75.6G -
rpool/data/vm-102-disk-1@rep_102_2018-08-15_17:08:28 61.0M - 75.6G -
rpool/data/vm-102-disk-1@rep_102_2018-08-15_20:07:40 68.4M - 75.6G -
rpool/data/vm-102-disk-1@rep_102_2018-08-16_05:22:16 68.4M - 75.6G -
rpool/data/vm-102-disk-1@rep_102_2018-08-16_11:19:01 1.46M - 75.6G -
rpool/data/vm-102-disk-1@rep_102_2018-08-16_11:19:21 1.39M - 75.6G -
rpool/data/vm-102-disk-1@rep_102_2018-08-16_14:04:35 44.4M - 75.6G -
rpool/data/vm-102-disk-1@rep_102_2018-08-16_17:03:48 43.5M - 75.6G -
rpool/data/vm-102-disk-1@rep_102_2018-08-16_20:02:45 52.8M - 75.6G -
rpool/data/vm-102-disk-1@rep_102_2018-08-17_00:03:51 63.9M - 75.6G -
rpool/data/vm-102-disk-1@rep_102_2018-08-17_04:04:03 61.9M - 75.6G -
rpool/data/vm-102-disk-1@rep_102_2018-08-17_08:03:45 48.1M - 75.6G -
rpool/data/vm-102-disk-1@rep_102_2018-08-17_11:02:28 51.9M - 75.6G -
rpool/data/vm-102-disk-1@rep_102_2018-08-17_14:11:25 72.1M - 75.6G -
rpool/data/vm-102-disk-1@rep_102_2018-08-17_17:16:03 0B - 75.6G -
如何列出所有VM的最新快照,以检查最新快照?
答案 0 :(得分:0)
可以通过以下方式获取最新拍摄的快照:
zfs list -t snapshot -o name,creation -s creation | tail -n1
如果使用大写字母-S
按属性降序排序,则在这种情况下返回第一个拍摄的快照:
zfs list -t snapshot -o name,creation -S creation | tail -n1
答案 1 :(得分:0)
这取决于您的具体情况,因为快照可以存在于嵌套文件系统的所有级别。
如果您确定每个VM的所有后代文件系统都在同一时间快照(使用LEFT JOIN
(SELECT ctt.customcodeid,
MAX(CASE WHEN ctt.codetagid = 7149 THEN Id ELSE 0 END) AS CslId,
MAX(CASE WHEN ctt.codetagid = 9736 THEN Id ELSE 0 END) AS LearnId,
MAX(CASE WHEN ctt.codetagid = 9735 THEN Id ELSE 0 END) AS PMId,
MAX(CASE WHEN ctt.codetagid = 10299 THEN Id ELSE 0 END) AS UpSell
FROM public.billing_codes_custom_tag ctt
WHERE ctt.codetagid IN (7149, 9736, 9735, 10299)
GROUP BY ctt.customcodeid
) codeLabel
ON codeLabel.customcodeid = bcc.id
而不是单独快照),则只需查看根级别(您可以使用所有根文件系统或自己将名称放在列表中):
zfs snapshot -r <root_filesystem>
如果后代上的快照与根不同,则不能使用#!/bin/bash
for i in $(zfs list -H -o name -d 0); do
zfs list -H -r -d 1 -t snap -o name -S creation "${i}" | head -n1
done
来限制深度,但需要显示所有快照。其余类似:
-d 1
您可能还想检查所有后代快照是否都符合与根快照相同的格式,或者是否所有后代都具有快照。但这两种情况都比较复杂。建议您查看#!/bin/bash
for i in $(zfs list -H -o name -d 0); do
zfs list -H -r -t snap -o name -S creation "${i}" | head -n1
done
选项/手册页,并使用zfs list
或awk
来实现。