projects
/
zfs-nexenta
/
.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed typo
[zfs-nexenta/.git]
/
zfs-autosnap
diff --git
a/zfs-autosnap
b/zfs-autosnap
index e7d939e9746453acfc0ac73d58f3cb5775f163fb..da650f53362fc2a35dca67aef2be9974b0f7aac4 100755
(executable)
--- a/
zfs-autosnap
+++ b/
zfs-autosnap
@@
-5,10
+5,13
@@
# It also employs an intelligent algorithm to roll off,
# or destroy, old snapshots.
# It also employs an intelligent algorithm to roll off,
# or destroy, old snapshots.
-PATH=/usr/sbin:/sbin:$PATH
+# source our configuration
+config="${0%/*}/zfs-scripts.conf"
+[ -e "${config}.dist" ] && . ${config}.dist
+[ -e "${config}" ] && . ${config}
-if [
-z "$SNAP_UNDER_TEST"
]; then
- exec >>
/var/log/
snap.log 2>&1
+if [
[ -z "$SNAP_UNDER_TEST" ]
]; then
+ exec >>
$logdir/zfs-auto
snap.log 2>&1
fi
# This script makes the following assumptions/requirements:
fi
# This script makes the following assumptions/requirements:
@@
-50,7
+53,6
@@
filesystem=$1
mountpoint=${2-/$1}
numsnapshots=${3-12}
maxagedays=${4-0}
mountpoint=${2-/$1}
numsnapshots=${3-12}
maxagedays=${4-0}
-lockdir="/tmp/${filesystem}.lock"
pool=`echo "$filesystem" | awk -F '/' '{ print $1 }'`
if [ -z "$filesystem" ] || [ -z "$mountpoint" ] || [ -z "$numsnapshots" ] || [ -z "$maxagedays" ]; then
pool=`echo "$filesystem" | awk -F '/' '{ print $1 }'`
if [ -z "$filesystem" ] || [ -z "$mountpoint" ] || [ -z "$numsnapshots" ] || [ -z "$maxagedays" ]; then
@@
-111,8
+113,8
@@
snapshot "${filesystem}@${datetime}"
minutes=$(echo $datetime | datetime_to_minutes)
minutes=$(echo $datetime | datetime_to_minutes)
-lockdir="/tmp/zfs-admin-lock"
if ! mkdir "$lockdir" >/dev/null 2>&1; then
if ! mkdir "$lockdir" >/dev/null 2>&1; then
+ echo "-W- The zfs filesystem has been locked down. Skipping snapshot cleanup."
exit 0
fi
cleanup() { rm -rf "$lockdir"; }
exit 0
fi
cleanup() { rm -rf "$lockdir"; }
@@
-130,8
+132,8
@@
for snapshot in $snapshots; do
case $((snapminutes2 % window)) in
0) ;;
*)
case $((snapminutes2 % window)) in
0) ;;
*)
- snapname=$(echo "$snapshot" |
-
sed 's,/\(.*\)/.zfs/snapshot/\(.*\),\1
@\2,')
+ snapname=$
{filesystem}$
(echo "$snapshot" |
+
sed 's,/\(.*\)/.zfs/snapshot/\(.*\),
@\2,')
destroy "$snapname"
;;
esac
destroy "$snapname"
;;
esac
@@
-140,8
+142,8
@@
for snapshot in $snapshots; do
window=$((window*2))
done
if [ $maxagedays -gt 0 ] && [ $age -gt $((maxagedays * 24 * 60)) ]; then
window=$((window*2))
done
if [ $maxagedays -gt 0 ] && [ $age -gt $((maxagedays * 24 * 60)) ]; then
- snapname=$(echo "$snapshot" |
-
sed 's,/\(.*\)/.zfs/snapshot/\(.*\),\1
@\2,')
+ snapname=$
{filesystem}$
(echo "$snapshot" |
+
sed 's,/\(.*\)/.zfs/snapshot/\(.*\),
@\2,')
destroy "$snapname"
fi
done
destroy "$snapname"
fi
done