Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Aug 2019 12:38:34 -0700
From:      David Christensen <dpchrist@holgerdanske.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: zfstools zfs-auto-snapshot "KEEP" argument issue
Message-ID:  <93352dce-dd9a-9592-b4ef-fba30407821d@holgerdanske.com>
In-Reply-To: <7d828758-faeb-4afa-766d-4f1fe1cae635@holgerdanske.com>
References:  <7d828758-faeb-4afa-766d-4f1fe1cae635@holgerdanske.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 8/1/19 9:29 AM, David Christensen wrote:
> Creating a snapshot with INTERVAL=foo works:
> 
> 2019-08-01 09:11:22 toor@soho ~
> # zfs-auto-snapshot foo 9
> 
> 2019-08-01 09:13:23 toor@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@soho ~
> # zfs-auto-snapshot foo 9
> 
> 2019-08-01 09:14:21 toor@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@soho ~
# zfs create bootpool/foo

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

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

2019-08-15 12:32:11 toor@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@soho ~
# touch /bootpool/foo/bar

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

2019-08-15 12:34:01 toor@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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?93352dce-dd9a-9592-b4ef-fba30407821d>