zfstools zfs-auto-snapshot "KEEP" argument issue

David Christensen dpchrist at holgerdanske.com
Thu Aug 15 19:39:03 UTC 2019


On 8/1/19 9:29 AM, David Christensen wrote:
> 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

I forgot about a zfs-auto-snapshot feature -- if the file system does 
not change when zfs-aut-snapshot runs, the old snapshot is kept and any 
new snapshots are thrown away before the KEEP option is applied.  The 
filesystem must change for a new snapshot to be kept:

2019-08-15 12:25:03 toor at soho ~
# zfs create bootpool/foo

2019-08-15 12:29:06 toor at soho ~
# ls -l /bootpool/foo/.zfs/snapshot/
total 0

2019-08-15 12:31:57 toor at soho ~
# zfs-auto-snapshot foo 9

2019-08-15 12:32:11 toor at soho ~
# ls -l /bootpool/foo/.zfs/snapshot | grep foo
drwxr-xr-x  2 root  wheel  3 Aug 15 12:31 zfs-auto-snap_foo-2019-08-15-12h32

2019-08-15 12:33:02 toor at soho ~
# touch /bootpool/foo/bar

2019-08-15 12:33:52 toor at soho ~
# zfs-auto-snapshot foo 9

2019-08-15 12:34:01 toor at soho ~
# ls -l /bootpool/foo/.zfs/snapshot | grep foo
drwxr-xr-x  2 root  wheel  3 Aug 15 12:31 zfs-auto-snap_foo-2019-08-15-12h32
drwxr-xr-x  2 root  wheel  3 Aug 15 12:31 zfs-auto-snap_foo-2019-08-15-12h33


Sorry for the noise.


David


More information about the freebsd-questions mailing list