forked from extern/zfs-auto-snapshot
Adding the 'none' interval, and having the Makefile generate PSTAMPS
This commit is contained in:
parent
f223b7e139
commit
ae57266595
1
Makefile
1
Makefile
@ -1,5 +1,6 @@
|
|||||||
pkg: clean
|
pkg: clean
|
||||||
mkdir -p proto
|
mkdir -p proto
|
||||||
|
cat `pwd`/src/pkginfo.s | sed -e s/~PSTAMP~/`uname -n``date +%Y%m%d%H%M%S`/g > `pwd`/src/pkginfo
|
||||||
pkgmk -f `pwd`/src/prototype -d `pwd`/proto -r `pwd`/src
|
pkgmk -f `pwd`/src/prototype -d `pwd`/proto -r `pwd`/src
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
@ -67,7 +67,11 @@ The properties each instance needs are:
|
|||||||
determine which filesystems to snapshot -
|
determine which filesystems to snapshot -
|
||||||
property inheritance is not respected.
|
property inheritance is not respected.
|
||||||
|
|
||||||
zfs/interval [ hours | days | months ]
|
zfs/interval [ hours | days | months | none]
|
||||||
|
When set to none, we don't take automatic snapshots, but
|
||||||
|
leave an SMF instance available for users to manually
|
||||||
|
fire the method script whenever they want - useful for
|
||||||
|
snapshotting on system events.
|
||||||
|
|
||||||
zfs/keep How many snapshots to retain. "all" keeps all snapshots.
|
zfs/keep How many snapshots to retain. "all" keeps all snapshots.
|
||||||
|
|
||||||
|
@ -77,20 +77,30 @@ LOG=""
|
|||||||
HAS_RECURSIVE=$(zfs snapshot 2>&1 | fgrep -e '-r')
|
HAS_RECURSIVE=$(zfs snapshot 2>&1 | fgrep -e '-r')
|
||||||
|
|
||||||
|
|
||||||
|
function get_pair {
|
||||||
|
NAME=$1
|
||||||
|
shift 2
|
||||||
|
echo "${NAME}=\"$@\""
|
||||||
|
echo "export ${NAME}"
|
||||||
|
}
|
||||||
|
|
||||||
# A function to pull in the variables from the FMRI given
|
# A function to pull in the variables from the FMRI given
|
||||||
# as the first argument.
|
# as the first argument.
|
||||||
function zfs_smf_props {
|
function zfs_smf_props {
|
||||||
|
|
||||||
SMF_PROPS=$(svcprop -p zfs $1 | \
|
IFS="
|
||||||
sed -e 's#^zfs/fs-name#zfs/fs_name#g' \
|
"
|
||||||
-e 's#^zfs/backup-lock#zfs/backup_lock#g' \
|
SMF_PROPS="$(svcprop -t -p zfs $1 |\
|
||||||
-e 's#^zfs/snapshot-children#zfs/snapshot_children#g' \
|
sed -e 's#zfs/fs-name#zfs/fs_name#g' \
|
||||||
-e 's#^zfs/backup-save-cmd#zfs/backup_save_cmd#g' \
|
-e 's#zfs/backup-lock#zfs/backup_lock#g' \
|
||||||
-e 's#zfs/##g' |\
|
-e 's#zfs/snapshot-children#zfs/snapshot_children#g' \
|
||||||
awk '{printf("%s=%s ",$1,$3)}')
|
-e 's#zfs/backup-save-cmd#zfs/backup_save_cmd#g' \
|
||||||
|
-e 's#zfs/##g' -e 's/$/,/g')"
|
||||||
for pair in $SMF_PROPS ; do
|
IFS=,
|
||||||
export "$pair"
|
for line in $SMF_PROPS ; do
|
||||||
|
IFS='
|
||||||
|
'
|
||||||
|
eval $(get_pair $line)
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,6 +196,10 @@ function add_cron_job { # $INTERVAL $PERIOD $OFFSET $FMRI
|
|||||||
TIMES=$(get_divisor 1 12 $PERIOD)
|
TIMES=$(get_divisor 1 12 $PERIOD)
|
||||||
ENTRY="0 0 1 $TIMES *"
|
ENTRY="0 0 1 $TIMES *"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
'none')
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Since we may have multiple instances all trying to start at
|
# Since we may have multiple instances all trying to start at
|
||||||
@ -231,6 +245,12 @@ function add_cron_job { # $INTERVAL $PERIOD $OFFSET $FMRI
|
|||||||
function unschedule_snapshots {
|
function unschedule_snapshots {
|
||||||
|
|
||||||
typeset FMRI=$1
|
typeset FMRI=$1
|
||||||
|
typeset INTERVAL=$interval
|
||||||
|
|
||||||
|
# interval set to 'none' means we don't want cron jobs
|
||||||
|
if [ "$INTERVAL" == "none" ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
# See notes on $LOCK_OWNED variable in function add_cron_job
|
# See notes on $LOCK_OWNED variable in function add_cron_job
|
||||||
LOCK_OWNED="false"
|
LOCK_OWNED="false"
|
||||||
@ -269,6 +289,7 @@ function take_snapshot {
|
|||||||
FMRI=$1
|
FMRI=$1
|
||||||
zfs_smf_props $FMRI
|
zfs_smf_props $FMRI
|
||||||
|
|
||||||
|
export LOG=$log
|
||||||
typeset DATE=$(date +%F-%H${SEP}%M${SEP}%S)
|
typeset DATE=$(date +%F-%H${SEP}%M${SEP}%S)
|
||||||
typeset FILESYS=$fs_name
|
typeset FILESYS=$fs_name
|
||||||
typeset KEEP=$keep
|
typeset KEEP=$keep
|
||||||
@ -649,13 +670,14 @@ function is_scrubbing { # POOL SCRUBLIST
|
|||||||
# created above, where the argument is the FMRI containing properties we can
|
# created above, where the argument is the FMRI containing properties we can
|
||||||
# consult to in order to actually take the snapshot.
|
# consult to in order to actually take the snapshot.
|
||||||
|
|
||||||
zfs_smf_props $SMF_FMRI
|
if [ -n "${SMF_FMRI}" ] ; then
|
||||||
export LOG=$(svcprop -p restarter/logfile $SMF_FMRI)
|
zfs_smf_props $SMF_FRI
|
||||||
|
export LOG=${log}
|
||||||
|
fi
|
||||||
|
|
||||||
# $1 start | stop | an FMRI that we want to take snapshots of.
|
# $1 start | stop | an FMRI that we want to take snapshots of.
|
||||||
case "$1" in
|
case "$1" in
|
||||||
'start')
|
'start')
|
||||||
|
|
||||||
schedule_snapshots $SMF_FMRI
|
schedule_snapshots $SMF_FMRI
|
||||||
if [ $? -eq 0 ] ; then
|
if [ $? -eq 0 ] ; then
|
||||||
result=$SMF_EXIT_OK
|
result=$SMF_EXIT_OK
|
||||||
|
@ -13,7 +13,7 @@ VERSION=0.11
|
|||||||
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.
|
||||||
PSTAMP=haiiro20080122113401
|
PSTAMP=haiiro20080730110036
|
||||||
VENDOR=Sun Microsystems, Inc.
|
VENDOR=Sun Microsystems, Inc.
|
||||||
HOTLINE=Please contact your local service provider
|
HOTLINE=Please contact your local service provider
|
||||||
EMAIL=tim.foster@sun.com
|
EMAIL=tim.foster@sun.com
|
||||||
|
Loading…
Reference in New Issue
Block a user