diff --git a/README.zfs-auto-snapshot.txt b/README.zfs-auto-snapshot.txt index 9ded47f..a4ac1c7 100644 --- a/README.zfs-auto-snapshot.txt +++ b/README.zfs-auto-snapshot.txt @@ -1,7 +1,7 @@ NAME -ZFS Automatic Snapshot SMF Service, version 0.11.2 +ZFS Automatic Snapshot SMF Service, version 0.11.3 DESCRIPTION @@ -79,6 +79,12 @@ The properties each instance needs are: set according to "zfs/interval" (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 of all child filesystems of the specified fs-name. This value is ignored when setting zfs/fs-name='//' diff --git a/src/lib/svc/method/zfs-auto-snapshot b/src/lib/svc/method/zfs-auto-snapshot index c5c7fdf..09ce68b 100644 --- a/src/lib/svc/method/zfs-auto-snapshot +++ b/src/lib/svc/method/zfs-auto-snapshot @@ -136,9 +136,6 @@ function schedule_snapshots { ;; esac - # for now, we're forcing the offset to be 0 seconds. - typeset OFFSET=0 - case $FILESYS in '//') ;; @@ -184,25 +181,37 @@ function add_cron_job { # $INTERVAL $PERIOD $OFFSET $FMRI typeset OFFSET=$3 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 'minutes') - TIMES=$(get_divisor 0 59 $PERIOD) + ((${PERIOD} < ${MINUTES})) && MINUTES=0 + TIMES=$(get_divisor ${MINUTES} 59 $PERIOD) ENTRY="$TIMES * * * *" ;; 'hours') - TIMES=$(get_divisor 0 23 $PERIOD) - ENTRY="0 $TIMES * * *" + ((${PERIOD} < ${HOURS})) && HOURS=0 + TIMES=$(get_divisor ${HOURS} 23 $PERIOD) + ENTRY="${MINUTES} $TIMES * * *" ;; 'days') - TIMES=$(get_divisor 1 31 $PERIOD) - ENTRY="0 0 $TIMES * *" + ((${PERIOD} < ${DAYS} || ${DAYS} == 0)) && DAYS=1 + TIMES=$(get_divisor ${DAYS} 31 $PERIOD) + ENTRY="${MINUTES} ${HOURS} $TIMES * *" ;; 'months') + ((${DAYS} == 0)) && DAYS=1 TIMES=$(get_divisor 1 12 $PERIOD) - ENTRY="0 0 1 $TIMES *" + ENTRY="${MINUTES} ${HOURS} ${DAYS} $TIMES *" ;; 'none') diff --git a/src/pkginfo b/src/pkginfo index 075859d..9614968 100644 --- a/src/pkginfo +++ b/src/pkginfo @@ -8,7 +8,7 @@ PKG=SUNWzfs-auto-snapshot NAME=ZFS Automatic Snapshot Service ARCH=all BASEDIR=/ -VERSION=0.11.2 +VERSION=0.11.3 MAXINST=1 CATEGORY=application DESC=Takes automatic snapshots of ZFS filesystems on a periodic basis.