From nobody Fri Feb 02 18:28:12 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TRPR11Vkzz59Dql; Fri, 2 Feb 2024 18:28:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TRPR10wWkz4gtx; Fri, 2 Feb 2024 18:28:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706898493; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=WlY1YF+/Vt5smMl/vLTprrf7OdeTI2STXtSSuV+QX1c=; b=gTe18f6IQcoJWNWQkW6s/v/H19Kmpi/OjXLnX7IkudcHokBqdD2hN6m1vqygGe8eu0Y+0s E2e4MFSeZnvsU/c8gPb4qtEHI031chj5ZrnvfgzWTvke7NaxoWd39PBOD/CuqFYiwD8LA0 ayYRJq3MU1KlhKGMkun989CFlnbEeGPEIS7aIEGpyugBAG3SVL5kqujmhSMGhcrj7EpFi1 sY12UtKr8H5fIh2IWREKuPHI74msXB7xE85u3mwqmCsV1Z12pCPR330YsQPqR+58BCa3yN 7oHHPRoeW8NQXmS5otDXF8zQYHDbtC2eBAfRH/693Qs9CCyxHnBTqQ5Hgwhe8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706898493; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=WlY1YF+/Vt5smMl/vLTprrf7OdeTI2STXtSSuV+QX1c=; b=X54UdVydA4AWiBUjrzTjRBvQTemy0QSMoynq4DDIKmo9xB16SLRjkrafC0omWR7k76WRft WOY7lg49q6HuosdnhvfKaOe9l5x60dY7VeFlvZ6q5spmiEfrJx59JEYO4xgtNHYJpxwdwv vTjEloN69Kyg0dLD5ODUbhYRGxz+3qFan15+jBgU0eA4mwpXC0IWDBxA/8R6AbSdtzip2P xGU8lIY8iXnRIzyHRuxDa4G0e/dTFJg752wIE10J5KFcDRdFfA23L373jkh8C8iMOL/Rvi O4HPH0BjpyLP0excQti5BMzLlTzMFHIfFLTuVpMKpKgwsxaIgSk2toZewVzJUg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706898493; a=rsa-sha256; cv=none; b=nYHhVu2h3YpDDLGE8JWjm+HhOoup2re79r+tE9tooLKRkqdwhKY2vulqo7KxAZcs2hIj9F yVRYQdv1EqFF2X4asUc0rrOSjmWli/ox+ycShFdz90EHXrvjqIR0QsI0jIM0SeGYsI2I1P v0TwXefJ9Mbg4wEPmKw3sDUkiLSOyaTh7ws17OhumPoSBHbXljbcvhdnbX28EeDk23AhXr GOK3nki4I6XQrKD13nIEDQaNDa80eqkTHWcIijW4FFiBYnXMXoeHtDIFm7ZkyB5MBQj+oe hIme8SzHk3VLzhsyEzagIOxmtL4wwnencpwwHl1DRa0doIwcXCdgJ4v+49XhRQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TRPR074hkzhVj; Fri, 2 Feb 2024 18:28:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 412ISC31086853; Fri, 2 Feb 2024 18:28:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 412ISC4g086850; Fri, 2 Feb 2024 18:28:12 GMT (envelope-from git) Date: Fri, 2 Feb 2024 18:28:12 GMT Message-Id: <202402021828.412ISC4g086850@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 4b1d3a30914e - main - daily/223.backup-zfs: improve daily_backup_zfs_verbose behaviour List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4b1d3a30914e176e9fd2c363db81c26124a8ee30 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=4b1d3a30914e176e9fd2c363db81c26124a8ee30 commit 4b1d3a30914e176e9fd2c363db81c26124a8ee30 Author: Lexi Winter AuthorDate: 2024-02-02 18:18:54 +0000 Commit: Warner Losh CommitDate: 2024-02-02 18:27:05 +0000 daily/223.backup-zfs: improve daily_backup_zfs_verbose behaviour - 223.backup-zfs would previously honour the daily_backup_zfs_verbose flag for zfs/zpool list, but not for the properties list. fix it to show a diff for both of these if requested. - if daily_backup_zfs_verbose was disabled, 223.backup-zfs would still set rc=1 if the backup files changed, which caused periodic(8) to send a useless email even if daily_show_success=NO was set. change this so that it only sets rc=1 if diff output is enabled, i.e. the output is actually useful to the admin. MFC after: 2 weeks Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1091 --- usr.sbin/periodic/etc/daily/223.backup-zfs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/usr.sbin/periodic/etc/daily/223.backup-zfs b/usr.sbin/periodic/etc/daily/223.backup-zfs index a49bbb2eaa04..e76421220a0b 100755 --- a/usr.sbin/periodic/etc/daily/223.backup-zfs +++ b/usr.sbin/periodic/etc/daily/223.backup-zfs @@ -13,6 +13,7 @@ then fi bak_dir=/var/backups +rc=0 rotate() { base_name=$1 @@ -20,12 +21,13 @@ rotate() { file="$bak_dir/$base_name" if [ -f "${file}.bak" ] ; then - rc=0 if cmp -s "${file}.bak" "${file}.tmp"; then rm "${file}.tmp" else - rc=1 - [ -n "$show_diff" ] && diff ${daily_diff_flags} "${file}.bak" "${file}.tmp" + if [ -n "$show_diff" ]; then + rc=1 + diff ${daily_diff_flags} "${file}.bak" "${file}.tmp" + fi mv "${file}.bak" "${file}.bak2" || rc=3 mv "${file}.tmp" "${file}.bak" || rc=3 fi @@ -36,6 +38,7 @@ rotate() { fi } +show="" case "$daily_backup_zfs_verbose" in [Yy][Ee][Ss]) show="YES" esac @@ -43,9 +46,9 @@ esac case "$daily_backup_zfs_enable" in [Yy][Ee][Ss]) - zpools=$(zpool list $daily_backup_zpool_list_flags) + zpools=$(zpool list $daily_backup_zpool_list_flags) - if [ -z "$zpools" ]; then + if [ -z "$zpools" ]; then echo 'daily_backup_zfs_enable is set to YES but no zpools found.' rc=2 else @@ -59,18 +62,17 @@ case "$daily_backup_zfs_enable" in rotate "zfs_list" $show fi ;; - *) rc=0;; esac case "$daily_backup_zfs_props_enable" in - [Yy][Ee][Ss]) + [Yy][Ee][Ss]) - zfs get $daily_backup_zfs_get_flags > "$bak_dir/zfs_props.tmp" - rotate "zfs_props" + zfs get $daily_backup_zfs_get_flags > "$bak_dir/zfs_props.tmp" + rotate "zfs_props" $show - zpool get $daily_backup_zpool_get_flags > "$bak_dir/zpool_props.tmp" - rotate "zpool_props" - ;; + zpool get $daily_backup_zpool_get_flags > "$bak_dir/zpool_props.tmp" + rotate "zpool_props" $show + ;; esac exit $rc