1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-24 00:45:52 +00:00

sysutils/freebsd-snapshot: allows to zfs filesystems to have unlimited snapshots

The periodic-snapshot supplied with the sysutils/freebsd-snapshot port
limits the total number of snapshots per file system to 20, which is
correct for ufs filesystems but does not apply to zfs which can have 2^64.

PR:		215828
Submitted by:	hostmaster@GTS.NET
Approved by:	maintainer timeout
This commit is contained in:
Koichiro Iwao 2019-02-26 04:51:49 +00:00
parent cc26adac52
commit 6cbef4ad09
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=493933
2 changed files with 46 additions and 1 deletions

View File

@ -3,7 +3,7 @@
PORTNAME= freebsd-snapshot
DISTVERSION= 20091208.1
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= sysutils
MASTER_SITES= https://people.freebsd.org/~rse/dist/

View File

@ -0,0 +1,45 @@
PR: 215828
--- periodic-snapshot.2016122900 2016-12-29 10:31:43.423980000 -0500
+++ periodic-snapshot 2017-01-05 11:21:16.767572000 -0500
@@ -47,6 +47,22 @@
* ) exit 0 ;;
esac
+# explicitly check whether we should take care of ZFS to
+# prevent us from _implicitly_ loading "zfs.ko" without reason
+zfs_enabled=`( \
+ if [ -r /etc/defaults/rc.conf ]; then \
+ . /etc/defaults/rc.conf; \
+ source_rc_confs; \
+ fi; \
+ . /etc/rc.subr; \
+ load_rc_config zfs; \
+ if checkyesno zfs_enable; then \
+ echo 'yes'; \
+ else \
+ echo 'no'; \
+ fi
+) 2>/dev/null || true`
+
# determine run-time tag and current hour
time_tag="$1"
time_hour=$((0 + `date '+%k'`))
@@ -87,10 +103,14 @@
OIFS="$IFS"; IFS="$IFS,"
for fs in $fs_list; do
IFS="$OIFS"
- # sanity check filesystem snapshot schedule
- if [ $((0 + $when_weekly + $when_daily + $when_hourly)) -gt 20 ]; then
- logger -p daemon.warning \
- "snapshot: schedule $schedule on filesystem $fs would require more than maximum number of 20 possible snapshots"
+ if [ ".$zfs_enabled" = .yes ] && (zfs list $fs) >/dev/null 2>&1; then
+ :
+ else
+ # sanity check filesystem snapshot schedule
+ if [ $((0 + $when_weekly + $when_daily + $when_hourly)) -gt 20 ]; then
+ logger -p daemon.warning \
+ "snapshot: schedule $schedule on ufs filesystem $fs would require more than maximum number of 20 possible snapshots"
+ fi
fi
# determine whether to make a snapshot