zfstools zfs-auto-snapshot "KEEP" argument issue

David Christensen dpchrist at holgerdanske.com
Thu Aug 1 16:29:30 UTC 2019


freebsd-questions:

Same machine as previous post, but with com.sun:auto-snapshot property 
case-sensitivity fixed:

2019-08-01 09:14:24 toor at soho ~
# zfs get -t filesystem com.sun:auto-snapshot | head
NAME                                            PROPERTY 
VALUE                  SOURCE
bootpool                                        com.sun:auto-snapshot 
true                   local
soho_zroot                                      com.sun:auto-snapshot 
true                   local
soho_zroot/ROOT                                 com.sun:auto-snapshot 
true                   inherited from soho_zroot
soho_zroot/ROOT/default                         com.sun:auto-snapshot 
true                   inherited from soho_zroot
soho_zroot/tmp                                  com.sun:auto-snapshot 
true                   inherited from soho_zroot
soho_zroot/usr                                  com.sun:auto-snapshot 
true                   inherited from soho_zroot
soho_zroot/usr/home                             com.sun:auto-snapshot 
true                   inherited from soho_zroot
soho_zroot/usr/ports                            com.sun:auto-snapshot 
true                   inherited from soho_zroot
soho_zroot/usr/src                              com.sun:auto-snapshot 
true                   inherited from soho_zroot


zfs-auto-snapshot accepts two arguments -- INTERVAL and KEEP:

2019-08-01 09:17:49 toor at soho ~
# zfs-auto-snapshot
Usage: /usr/local/sbin/zfs-auto-snapshot [-dknpuv] <INTERVAL> <KEEP>
     -d              Show debug output.
     -k              Keep zero-sized snapshots.
     -n              Do a dry-run. Nothing is committed. Only show what 
would be done.
     -p              Create snapshots in parallel.
     -P pool         Act only on the specified pool.
     -u              Use UTC for snapshots.
     -v              Show what is being done.
     INTERVAL        The interval to snapshot.
     KEEP            How many snapshots to keep.


Creating a snapshot with INTERVAL=foo works:

2019-08-01 09:11:22 toor at soho ~
# zfs-auto-snapshot foo 9

2019-08-01 09:13:23 toor at soho ~
# ls -l /bootpool/.zfs/snapshot/ | grep foo 

drwxr-xr-x  3 root  wheel  3 May 23 22:21 zfs-auto-snap_foo-2019-08-01-09h13


But if I wait a minute and do another run, KEEP=9 is not honored 
(previous snapshot is removed, when it should have been kept):

2019-08-01 09:13:38 toor at soho ~
# zfs-auto-snapshot foo 9

2019-08-01 09:14:21 toor at soho ~
# ls -l /bootpool/.zfs/snapshot/ | grep foo
drwxr-xr-x  3 root  wheel  3 May 23 22:21 zfs-auto-snap_foo-2019-08-01-09h14


Also fails with single quotes:

2019-08-01 09:19:46 toor at soho ~
# zfs-auto-snapshot 'foo' '9'

2019-08-01 09:24:05 toor at soho ~
# ls -l /bootpool/.zfs/snapshot/ | grep foo
drwxr-xr-x  3 root  wheel  3 May 23 22:21 zfs-auto-snap_foo-2019-08-01-09h24


Any ideas?


David


More information about the freebsd-questions mailing list