大网数据广告活动
服务器运维问答

How to set the number of snapshots zfs-auto-snapshot should retain?

· 52CE 我爱测

Using the below zfs-auto-snapshot commands, how to specify to keep 52 weekly snapshots and infinite number of monthly snapshots? sudo zfs set com.sun:auto-snapshot=true storage sudo zfs set com.sun:auto-snapshot:weekly=true stora…

问题原文

原帖链接 · Greg · CC BY-SA 3.0

Using the below zfs-auto-snapshot commands, how to specify to keep 52 weekly snapshots and infinite number of monthly snapshots?

sudo zfs set com.sun:auto-snapshot=true storage
sudo zfs set com.sun:auto-snapshot:weekly=true storage
sudo zfs set com.sun:auto-snapshot:monthly=true storage

When I specified it as a keyword or argument it failed both times:

sudo zfs set com.sun:auto-snapshot:weekly=true storage keep=52
cannot open 'keep=52': invalid dataset name

sudo zfs set com.sun:auto-snapshot:weekly=true storage --keep=52
cannot open '--keep=52': invalid dataset name

已采纳解答

原帖链接 · ewwhite · CC BY-SA 3.0

Here is a sample of one of my system's /etc/cron.d/zfs-auto-snapshot.

PATH="/usr/bin:/bin:/usr/sbin:/sbin"

*/5 * * * * root /sbin/zfs-auto-snapshot -q -g --label=frequent --keep=24 //
00 * * * * root /sbin/zfs-auto-snapshot -q -g --label=hourly --keep=24 //
59 23 * * * root /sbin/zfs-auto-snapshot -q -g --label=daily --keep=14 //
59 23 * * 0 root /sbin/zfs-auto-snapshot -q -g --label=weekly --keep=4 //
00 00 1 * * root /sbin/zfs-auto-snapshot -q -g --label=monthly --keep=18 //

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-06-15)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。