6777694 Need ability to control when auto-snapshots are taken

This commit is contained in:
Luca Morettoni
2008-12-03 11:55:19 +01:00
parent 6d345ee5f7
commit fabafc5db9
3 changed files with 26 additions and 11 deletions

View File

@@ -1,7 +1,7 @@
NAME NAME
ZFS Automatic Snapshot SMF Service, version 0.11.2 ZFS Automatic Snapshot SMF Service, version 0.11.3
DESCRIPTION DESCRIPTION
@@ -79,6 +79,12 @@ The properties each instance needs are:
set according to "zfs/interval" set according to "zfs/interval"
(eg. every 10 days) (eg. every 10 days)
zfs/offset The time from the start of the current interval at which
snapshots should be taken, expressed in seconds. For example
to take snapshots hourly at 15 minutes into the hour,
zfs/offset = 900 (60 sec. * 15) To take daily snapshots at
15:43, zfs/offset = 56580.
zfs/snapshot-children "true" if you would like to recursively take snapshots zfs/snapshot-children "true" if you would like to recursively take snapshots
of all child filesystems of the specified fs-name. of all child filesystems of the specified fs-name.
This value is ignored when setting zfs/fs-name='//' This value is ignored when setting zfs/fs-name='//'

View File

@@ -136,9 +136,6 @@ function schedule_snapshots {
;; ;;
esac esac
# for now, we're forcing the offset to be 0 seconds.
typeset OFFSET=0
case $FILESYS in case $FILESYS in
'//') '//')
;; ;;
@@ -184,25 +181,37 @@ function add_cron_job { # $INTERVAL $PERIOD $OFFSET $FMRI
typeset OFFSET=$3 typeset OFFSET=$3
typeset FMRI=$4 typeset FMRI=$4
DAYS=$((${OFFSET} / 86400))
LEFT=$((${OFFSET} % 86400))
HOURS=$((${LEFT} / 3600))
LEFT=$((${LEFT} % 3600))
MINUTES=$((${LEFT} / 60))
((${DAYS} > 31)) && DAYS=31
case $INTERVAL in case $INTERVAL in
'minutes') 'minutes')
TIMES=$(get_divisor 0 59 $PERIOD) ((${PERIOD} < ${MINUTES})) && MINUTES=0
TIMES=$(get_divisor ${MINUTES} 59 $PERIOD)
ENTRY="$TIMES * * * *" ENTRY="$TIMES * * * *"
;; ;;
'hours') 'hours')
TIMES=$(get_divisor 0 23 $PERIOD) ((${PERIOD} < ${HOURS})) && HOURS=0
ENTRY="0 $TIMES * * *" TIMES=$(get_divisor ${HOURS} 23 $PERIOD)
ENTRY="${MINUTES} $TIMES * * *"
;; ;;
'days') 'days')
TIMES=$(get_divisor 1 31 $PERIOD) ((${PERIOD} < ${DAYS} || ${DAYS} == 0)) && DAYS=1
ENTRY="0 0 $TIMES * *" TIMES=$(get_divisor ${DAYS} 31 $PERIOD)
ENTRY="${MINUTES} ${HOURS} $TIMES * *"
;; ;;
'months') 'months')
((${DAYS} == 0)) && DAYS=1
TIMES=$(get_divisor 1 12 $PERIOD) TIMES=$(get_divisor 1 12 $PERIOD)
ENTRY="0 0 1 $TIMES *" ENTRY="${MINUTES} ${HOURS} ${DAYS} $TIMES *"
;; ;;
'none') 'none')

View File

@@ -8,7 +8,7 @@ PKG=SUNWzfs-auto-snapshot
NAME=ZFS Automatic Snapshot Service NAME=ZFS Automatic Snapshot Service
ARCH=all ARCH=all
BASEDIR=/ BASEDIR=/
VERSION=0.11.2 VERSION=0.11.3
MAXINST=1 MAXINST=1
CATEGORY=application CATEGORY=application
DESC=Takes automatic snapshots of ZFS filesystems on a periodic basis. DESC=Takes automatic snapshots of ZFS filesystems on a periodic basis.