From e7aa72160f854bd255373a5a6bd9981c4977c46d Mon Sep 17 00:00:00 2001 From: "Andrew J. Hesford" Date: Mon, 16 Dec 2019 11:19:53 -0500 Subject: [PATCH] Support suffix matching in the same style as prefix matching. --- README.md | 10 ++++++++++ man/zfs-prune-snapshots.1 | 7 +++++++ man/zfs-prune-snapshots.md | 7 +++++++ zfs-prune-snapshots | 17 +++++++++++++++-- 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8adad4d..d14e7b1 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,11 @@ with the string "autosnap_" zfs-prune-snapshots -p 'autosnap_' 1M zones +Remove snapshots older than two months on the tank pool that end +with the string "_frequent" + + zfs-prune-snapshots -s '_frequent' 2M tank + Timespec -------- @@ -64,6 +69,10 @@ Usage remove snapshots older than a month on the zones pool that start with the string "autosnap_" + # zfs-prune-snapshots -s '_frequent' 2M tank + remove snapshots older than two months on the tank pool that end + with the string "_frequent" + timespec the first argument denotes how old a snapshot must be for it to be considered for deletion - possible specifiers are @@ -80,6 +89,7 @@ Usage -h print this message and exit -n dry-run, don't actually delete snapshots -p snapshot prefix string to match + -s snapshot suffix string to match -q quiet, do not printout removed snapshots -v increase verbosity -V print the version number and exit diff --git a/man/zfs-prune-snapshots.1 b/man/zfs-prune-snapshots.1 index 6ae4cf6..73b7a6c 100644 --- a/man/zfs-prune-snapshots.1 +++ b/man/zfs-prune-snapshots.1 @@ -21,6 +21,9 @@ dry\-run, don't actually delete snapshots \fB\fC\-p \fR snapshot prefix string to match .TP +\fB\fC\-s \fR +snapshot suffix string to match +.TP \fB\fC\-q\fR quiet, do not printout removed snapshots .TP @@ -65,6 +68,10 @@ tank2/backup \fB\fCzfs\-prune\-snapshots \-p 'autosnap_' 1M zones\fR Remove snapshots older than a month on the zones pool that start with the string \fB\fC"autosnap_"\fR +.TP +\fB\fCzfs\-prune\-snapshots \-s '_frequent' 2M tank\fR +Remove snapshots older than two months on the tank pool that end with the +string \fB\fC"_frequent"\fR .SH BUGS .PP \[la]https://github.com/bahamas10/zfs-prune-snapshots\[ra] diff --git a/man/zfs-prune-snapshots.md b/man/zfs-prune-snapshots.md index f6a5ee3..598c8a4 100644 --- a/man/zfs-prune-snapshots.md +++ b/man/zfs-prune-snapshots.md @@ -30,6 +30,9 @@ OPTIONS `-p ` snapshot prefix string to match +`-s ` + snapshot suffix string to match + `-q` quiet, do not printout removed snapshots @@ -77,6 +80,10 @@ EXAMPLES Remove snapshots older than a month on the zones pool that start with the string `"autosnap_"` +`zfs-prune-snapshots -s '_frequent' 2M tank` + Remove snapshots older than two months on the tank pool that end with the + string `"_frequent"` + BUGS ---- diff --git a/zfs-prune-snapshots b/zfs-prune-snapshots index 857bb7b..7f35834 100755 --- a/zfs-prune-snapshots +++ b/zfs-prune-snapshots @@ -11,7 +11,7 @@ VERSION='v1.0.1' usage() { local prog=${0##*/} cat <<-EOF - usage: $prog [-hnv] [-p [[dataset1] ...] + usage: $prog [-hnv] [-p ] [-s ]