phuesler / zfs-scripts Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
This will not work on SunOS platforms, so I've changed some bits:
--- delete_snapshots.sh Sat Dec 5 10:03:02 2015
+++ /opt/custom/sbin/delete_snapshots Sat Dec 5 10:02:00 2015
@@ -79,6 +79,8 @@
platform='bsd'
elif [[ "$unamestr" == 'Darwin' ]]; then
platform='bsd'
+elif [[ "$unamestr" == 'SunOS' ]]; then
+ platform='sunos'
else
echo -e "unknown platform $unamestr 1>&2"
exit 1
@@ -93,6 +95,8 @@
if [[ "$platform" == 'linux' ]]; then
compare_timestamp=`date --date="-$(echo $compare_seconds) seconds" +"%s"`
+elif [[ "$platform" == 'sunos' ]]; then
+compare_timestamp=$((`date +"%s"` - $compare_seconds))
else
compare_timestamp=`date -j -v-$(echo $compare_seconds)S +"%s"`
fi
@@ -99,7 +103,7 @@
# get a list of snapshots sorted by creation date, so that we get the oldest first
# This will allow us to skip the loop early
-snapshots=`zfs list -H -t snapshot -o name,creation -s creation | grep $pattern`
+snapshots=`zfs list -H -t snapshot -o name,creation -s creation -p | grep $pattern`
if [[ -z $snapshots ]]; then
echo "no snapshots found for pattern $pattern"
@@ -112,14 +116,8 @@
IFS=$'\n'
for line in $snapshots; do
snapshot=`echo $line | cut -f 1`
- creation_date=`echo $line | cut -f 2`
+ creation_date_timestamp=`echo $line | cut -f 2`
- if [[ "$platform" == 'linux' ]]; then
- creation_date_timestamp=`date --date="$creation_date" "+%s"`
- else
- creation_date_timestamp=`date -j -f "%a %b %d %H:%M %Y" "$creation_date" "+%s"`
- fi
-
# Check if the creation date of a snapshot is less than our compare date
# Meaning if it is older than our compare date
# It is younger, we can stop processing since we the list is sorted by
@@ -130,10 +128,10 @@
echo "DELETE: $snapshot from $creation_date"
zfs destroy $snapshot
else
- echo "WOULD DELETE: $snapshot from $creation_date"
+ echo "WOULD DELETE: $snapshot"
fi
else
- echo "KEEP: $snapshot from $creation_date"
+ echo "KEEP: $snapshot"
echo "No more snapshots to be processed for $pattern. Skipping.."
break
fi
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.