summaryrefslogtreecommitdiff
path: root/filesystems/zfsnap2
diff options
context:
space:
mode:
Diffstat (limited to 'filesystems/zfsnap2')
-rw-r--r--filesystems/zfsnap2/Makefile56
-rw-r--r--filesystems/zfsnap2/distinfo3
-rw-r--r--filesystems/zfsnap2/files/patch-periodic_xPERIODICx__zfsnap.sh48
-rw-r--r--filesystems/zfsnap2/pkg-descr16
-rw-r--r--filesystems/zfsnap2/pkg-plist14
5 files changed, 137 insertions, 0 deletions
diff --git a/filesystems/zfsnap2/Makefile b/filesystems/zfsnap2/Makefile
new file mode 100644
index 000000000000..559ad86aef7b
--- /dev/null
+++ b/filesystems/zfsnap2/Makefile
@@ -0,0 +1,56 @@
+PORTNAME= zfsnap
+DISTVERSIONPREFIX= v
+DISTVERSION= 2.0.0-beta3
+PORTREVISION= 4
+CATEGORIES= filesystems sysutils
+PKGNAMESUFFIX= 2
+
+MAINTAINER= mm@FreeBSD.org
+COMMENT= Portable performant script to make rolling ZFS snapshots easy
+WWW= https://github.com/zfsnap/zfsnap
+
+LICENSE= BSD3CLAUSE
+LICENSE_FILE= ${WRKSRC}/LICENSE
+
+NO_BUILD= yes
+USE_GITHUB= yes
+
+OPTIONS_DEFINE= BASH ZSH DOCS
+OPTIONS_DEFAULT= BASH ZSH
+OPTIONS_SUB= yes
+
+PORTDOCS= AUTHORS NEWS PORTABILITY README.md
+
+PERIODICDIR?= ${PREFIX}/etc/periodic
+
+post-patch:
+ @${REINPLACE_CMD} -e "s,# ZFSNAP_LIB_DIR=.*,ZFSNAP_LIB_DIR=${PREFIX}/share/zfsnap,g" ${WRKSRC}/sbin/zfsnap.sh
+.for period in daily weekly monthly
+ @${SED} -e "s/xPERIODICx/${period}/g" -e "s#xPREFIXx#${PREFIX}/sbin#g" ${WRKSRC}/periodic/xPERIODICx_zfsnap.sh > ${WRKSRC}/periodic/${period}_zfsnap.sh
+.endfor
+
+do-install:
+ ${INSTALL_SCRIPT} ${WRKSRC}/sbin/zfsnap.sh ${STAGEDIR}${PREFIX}/sbin/zfsnap
+ cd ${WRKSRC}/share && ${COPYTREE_SHARE} zfsnap ${STAGEDIR}${PREFIX}/share/
+ cd ${WRKSRC} && ${COPYTREE_SHARE} completion ${STAGEDIR}${PREFIX}/share/zfsnap
+.for period in daily weekly monthly
+ @${MKDIR} ${STAGEDIR}${PERIODICDIR}/${period}
+ ${INSTALL_SCRIPT} ${WRKSRC}/periodic/${period}_zfsnap.sh ${STAGEDIR}${PERIODICDIR}/${period}/402.zfsnap
+.endfor
+ ${INSTALL_MAN} ${WRKSRC}/man/man8/zfsnap.8 ${STAGEDIR}${PREFIX}/share/man/man8/zfsnap.8
+ ${MKDIR} ${STAGEDIR}${DOCSDIR}
+.for file in ${PORTDOCS}
+ ${INSTALL_DATA} ${WRKSRC}/${file} ${STAGEDIR}${DOCSDIR}/${file}
+.endfor
+
+post-install-BASH-on:
+ ${MKDIR} ${STAGEDIR}${PREFIX}/etc/bash_completion.d
+ ${LN} -s ../../share/zfsnap/completion/zfsnap-completion.bash \
+ ${STAGEDIR}${PREFIX}/etc/bash_completion.d/zfsnap.sh
+
+post-install-ZSH-on:
+ ${MKDIR} ${STAGEDIR}${PREFIX}/share/zsh/site-functions
+ ${LN} -s ../../zfsnap/completion/zfsnap-completion.zsh \
+ ${STAGEDIR}${PREFIX}/share/zsh/site-functions/_zfsnap
+
+.include <bsd.port.mk>
diff --git a/filesystems/zfsnap2/distinfo b/filesystems/zfsnap2/distinfo
new file mode 100644
index 000000000000..944dc6c3b08e
--- /dev/null
+++ b/filesystems/zfsnap2/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1478466865
+SHA256 (zfsnap-zfsnap-v2.0.0-beta3_GH0.tar.gz) = d73be34b58d94b89010e2be6fc3d34bdc34b9675aaa2bebfe446dffb683e45d3
+SIZE (zfsnap-zfsnap-v2.0.0-beta3_GH0.tar.gz) = 29973
diff --git a/filesystems/zfsnap2/files/patch-periodic_xPERIODICx__zfsnap.sh b/filesystems/zfsnap2/files/patch-periodic_xPERIODICx__zfsnap.sh
new file mode 100644
index 000000000000..3b8bf6daee22
--- /dev/null
+++ b/filesystems/zfsnap2/files/patch-periodic_xPERIODICx__zfsnap.sh
@@ -0,0 +1,48 @@
+--- periodic/xPERIODICx_zfsnap.sh.orig 2020-07-28 02:17:05 UTC
++++ periodic/xPERIODICx_zfsnap.sh
+@@ -11,23 +11,29 @@ fi
+
+ # xPERIODICx_zfsnap_enable - Enable xPERIODICx snapshots (values: YES | NO)
+ # xPERIODICx_zfsnap_flags - `zfsnap snapshot` flags
+-# xPERIODICx_zfsnap_fs - Space-separated ZFS filesystems to create non-recursive snapshots
+-# xPERIODICx_zfsnap_recursive_fs - Space-separated ZFS filesystems to create recursive snapshots
++# xPERIODICx_zfsnap_delete_flags - `zfsnap destroy` flags
++# xPERIODICx_zfsnap_fs - Space-separated ZFS filesystems to manage non-recursive snapshots
++# xPERIODICx_zfsnap_recursive_fs - Space-separated ZFS filesystems to manage recursive snapshots
+ # xPERIODICx_zfsnap_ttl - Explicit TTL value
+ # xPERIODICx_zfsnap_verbose - Verbose output (values: YES | NO)
+ # xPERIODICx_zfsnap_enable_prefix - Create snapshots with prefix (values: YES | NO) (Default = YES)
+ # xPERIODICx_zfsnap_prefix - set prefix for snapshots (Default = xPERIODICx)
++# xPERIODICx_zfsnap_delete_prefixes - Space-separated list of prefixes of expired zfsnap snapshots to delete
+
+ case "${xPERIODICx_zfsnap_enable-"NO"}" in
+ [Yy][Ee][Ss])
+- OPTIONS="$xPERIODICx_zfsnap_flags"
++ CREATE_OPTIONS="$xPERIODICx_zfsnap_flags"
++ DESTROY_OPTIONS="$xPERIODICx_zfsnap_delete_flags"
+
+ case "${xPERIODICx_zfsnap_verbose-"NO"}" in
+- [Yy][Ee][Ss]) OPTIONS="$OPTIONS -v" ;;
++ [Yy][Ee][Ss])
++ CREATE_OPTIONS="$CREATE_OPTIONS -v"
++ DESTROY_OPTIONS="$DESTROY_OPTIONS -v"
++ ;;
+ esac
+
+ case "${xPERIODICx_zfsnap_enable_prefix-"YES"}" in
+- [Yy][Ee][Ss]) OPTIONS="$OPTIONS -p ${xPERIODICx_zfsnap_prefix:-"xPERIODICx-"}" ;;
++ [Yy][Ee][Ss]) CREATE_OPTIONS="$CREATE_OPTIONS -p ${xPERIODICx_zfsnap_prefix:-"xPERIODICx-"}" ;;
+ esac
+
+ case 'xPERIODICx' in
+@@ -49,7 +55,9 @@ case "${xPERIODICx_zfsnap_enable-"NO"}" in
+ ;;
+ esac
+
+- xPREFIXx/zfsnap snapshot $OPTIONS -a ${xPERIODICx_zfsnap_ttl:-"$default_ttl"} $xPERIODICx_zfsnap_fs -r $xPERIODICx_zfsnap_recursive_fs
++ # Destroy before create, just in case the pool is out of space
++ xPREFIXx/zfsnap destroy $DESTROY_OPTIONS -p "hourly- daily- weekly- monthly- reboot- $xPERIODICx_zfsnap_delete_prefixes" $xPERIODICx_zfsnap_fs -r $xPERIODICx_zfsnap_recursive_fs && \
++ xPREFIXx/zfsnap snapshot $CREATE_OPTIONS -a ${xPERIODICx_zfsnap_ttl:-"$default_ttl"} $xPERIODICx_zfsnap_fs -r $xPERIODICx_zfsnap_recursive_fs
+ exit $?
+ ;;
+
diff --git a/filesystems/zfsnap2/pkg-descr b/filesystems/zfsnap2/pkg-descr
new file mode 100644
index 000000000000..e5aa55629cad
--- /dev/null
+++ b/filesystems/zfsnap2/pkg-descr
@@ -0,0 +1,16 @@
+zfsnap makes rolling ZFS snapshots easy and - with cron - automatic.
+
+The main advantages of zfsnap are its portability, simplicity, and performance.
+It is written purely in /bin/sh and does not require any additional software -
+other than a few core *nix utilies.
+
+zfsnap stores all the information it needs about a snapshot directly in its
+name; no database or special ZFS properties are needed. The information is
+stored in a way that is human readable, making it much easier for a sysadmin to
+manage and audit backup schedules.
+
+Snapshot names are in the format of pool/fs@[prefix]Timestamp--TimeToLive
+(e.g. pool/fs@weekly-2014-04-07_05.30.00--6m). The prefix is optional but can
+be quite useful for filtering, Timestamp is the date and time when the snapshot
+was created, and TimeToLive (TTL) is the amount of time the snapshot will be
+kept until it can be deleted.
diff --git a/filesystems/zfsnap2/pkg-plist b/filesystems/zfsnap2/pkg-plist
new file mode 100644
index 000000000000..865f12042d3e
--- /dev/null
+++ b/filesystems/zfsnap2/pkg-plist
@@ -0,0 +1,14 @@
+%%BASH%%etc/bash_completion.d/zfsnap.sh
+etc/periodic/daily/402.zfsnap
+etc/periodic/monthly/402.zfsnap
+etc/periodic/weekly/402.zfsnap
+share/man/man8/zfsnap.8.gz
+sbin/zfsnap
+%%DATADIR%%/commands/destroy.sh
+%%DATADIR%%/commands/recurseback.sh
+%%DATADIR%%/commands/snapshot.sh
+%%DATADIR%%/completion/zfsnap-completion.bash
+%%DATADIR%%/completion/zfsnap-completion.tcsh
+%%DATADIR%%/completion/zfsnap-completion.zsh
+%%DATADIR%%/core.sh
+%%ZSH%%share/zsh/site-functions/_zfsnap