From owner-freebsd-questions@freebsd.org Thu Aug 15 19:39:03 2019 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 24A85B44D0 for ; Thu, 15 Aug 2019 19:39:03 +0000 (UTC) (envelope-from dpchrist@holgerdanske.com) Received: from holgerdanske.com (holgerdanske.com [IPv6:2001:470:0:19b::b869:801b]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "holgerdanske.com", Issuer "holgerdanske.com" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 468cFy0d7hz4LPJ for ; Thu, 15 Aug 2019 19:39:01 +0000 (UTC) (envelope-from dpchrist@holgerdanske.com) Received: from 99.100.19.101 ([99.100.19.101]) by holgerdanske.com with ESMTPSA (ECDHE-RSA-AES128-GCM-SHA256:TLSv1.2:Kx=ECDH:Au=RSA:Enc=AESGCM(128):Mac=AEAD) (SMTP-AUTH username dpchrist@holgerdanske.com, mechanism PLAIN) for ; Thu, 15 Aug 2019 12:38:50 -0700 Subject: Re: zfstools zfs-auto-snapshot "KEEP" argument issue To: freebsd-questions@freebsd.org References: <7d828758-faeb-4afa-766d-4f1fe1cae635@holgerdanske.com> From: David Christensen Message-ID: <93352dce-dd9a-9592-b4ef-fba30407821d@holgerdanske.com> Date: Thu, 15 Aug 2019 12:38:34 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <7d828758-faeb-4afa-766d-4f1fe1cae635@holgerdanske.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 468cFy0d7hz4LPJ X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of dpchrist@holgerdanske.com has no SPF policy when checking 2001:470:0:19b::b869:801b) smtp.mailfrom=dpchrist@holgerdanske.com X-Spamd-Result: default: False [-3.57 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; IP_SCORE(-1.51)[ipnet: 2001:470::/32(-4.47), asn: 6939(-3.04), country: US(-0.05)]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; AUTH_NA(1.00)[]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-1.00)[-0.999,0]; DMARC_NA(0.00)[holgerdanske.com]; NEURAL_HAM_SHORT(-0.96)[-0.958,0]; R_SPF_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Aug 2019 19:39:03 -0000 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