Linux

zfs-auto-snapshot 僅對頻繁的快照進行快照,即使每小時、每日、每周和每月快照設置為 True

  • June 17, 2017

zfs-auto-snapshot已安裝並應用了以下設置:

# zfs get all backup
NAME    PROPERTY                        VALUE                           SOURCE
backup  com.sun:auto-snapshot           true                            local
backup  com.sun:auto-snapshot:monthly   true                            local
backup  com.sun:auto-snapshot:weekly    true                            local
backup  com.sun:auto-snapshot:hourly    true                            local
backup  com.sun:auto-snapshot:frequent  true                            local
backup  com.sun:auto-snapshot:daily     true                            local

安裝已經半週了,檢查快照時,只存在四個最頻繁的快照:

# zfs list -t snapshot
NAME                                            USED  AVAIL  REFER  MOUNTPOINT
backup@zfs-auto-snap_frequent-2017-06-17-0645  3.06M      -   123G  -
backup@zfs-auto-snap_frequent-2017-06-17-0700  1.57M      -   123G  -
backup@zfs-auto-snap_frequent-2017-06-17-0715  1.43M      -   123G  -
backup@zfs-auto-snap_frequent-2017-06-17-0730   928K      -   123G  -

您應該閱讀文件或原始碼。

打開/sbin/zfs-auto-snapshot並設置系統預設選項。

# Set default program options.
opt_backup_full=''
opt_backup_incremental=''
opt_default_exclude='1'
opt_dry_run=''
opt_event='-'
opt_fast_zfs_list='1'
opt_keep=''
opt_label=''
opt_prefix='snap'
opt_recursive=''
opt_sep='_'
opt_setauto=''
opt_syslog=''
opt_skip_scrub=''
opt_verbose=''
opt_pre_snapshot=''
opt_post_snapshot=''
opt_do_snapshots='1'

中的 cron 腳本/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=4 //

引用自:https://serverfault.com/questions/856353