Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add the ability for both Life-Preserver and Warden to set an optional

comment on snapshots at creation time
  • Loading branch information...
commit cca8f57b2fecf4c80db306b7917211874b35820d 1 parent ee5baaa
@kmoore134 kmoore134 authored
View
14 src-sh/lpreserver/backend/functions.sh
@@ -70,11 +70,23 @@ mkZFSSnap() {
fi
zdate=`date +%Y-%m-%d-%H-%M-%S`
zfs snapshot $flags ${1}@$2${zdate} >${CMDLOG} 2>${CMDLOG}
+
+ # Do we have a comment to set?
+ if [ -n "$3" ] ; then
+ zfs set lpreserver:comment="$3" ${1}@${2}${zdate}
+ fi
+
return $?
}
listZFSSnap() {
- zfs list -d 1 -t snapshot | grep -e "^${1}@" | awk '{print $1}'
+ echo "Snapshot Comment"
+ echo "-----------------------------------------------"
+ for i in `zfs list -d 1 -t snapshot | grep -e "^${1}@" | awk '{print $1}'`
+ do
+ comment=`zfs get -o value lpreserver:comment $i | grep -v "VALUE"`
+ echo "$i $comment"
+ done
}
rmZFSSnap() {
View
2  src-sh/lpreserver/backend/runsnap.sh
@@ -177,7 +177,7 @@ fi
# Create the snapshot now with the "auto-" tag
echo_log "Creating snapshot on ${DATASET}"
-mkZFSSnap "${DATASET}" "auto-"
+mkZFSSnap "${DATASET}" "auto-" "Automated Snapshot"
if [ $? -ne 0 ] ; then
echo_log "ERROR: Failed creating snapshot on ${DATASET}"
queue_msg "ERROR: Failed creating snapshot on ${DATASET} @ `date`\n\r`cat $CMDLOG`"
View
4 src-sh/lpreserver/backend/zfsmksnap.sh
@@ -22,11 +22,13 @@ if [ -z "${SNAPNAME}" ]; then
exit_err "No snapshot name specified!"
fi
+COMMENT="$3"
+
# Make the snapshot now
snapStat=0
echo_log "Creating snapshot on ${DATASET}"
-mkZFSSnap "${DATASET}" "${SNAPNAME}"
+mkZFSSnap "${DATASET}" "${SNAPNAME}" "$COMMENT"
if [ $? -ne 0 ] ; then
echo_log "ERROR: Failed creating snapshot on ${DATASET}"
queue_msg "Snapshot ERROR" "ERROR: Failed creating snapshot on ${DATASET} @ `date`\n\r`cat $CMDLOG`"
View
7 src-sh/lpreserver/lpreserver
@@ -386,7 +386,7 @@ Create a new ZFS snapshot of a dataset
Usage:
- lpreserver mksnap <dataset> <snapshotname>
+ lpreserver mksnap <dataset> <snapshotname> <comment>
Example:
@@ -394,7 +394,7 @@ Example:
or
- lpreserver mksnap tank1/usr/home/kris mysnapshot
+ lpreserver mksnap tank1/usr/home/kris mysnapshot \"Added user bob\"
NOTE:
By default snapshots are recursive and will create snapshots
@@ -496,7 +496,8 @@ case "$1" in
mksnap) require_root
DATASET="$2"
SNAPNAME="$3"
- ${PROGDIR}/backend/zfsmksnap.sh "${DATASET}" "$SNAPNAME"
+ COMMENT="$4"
+ ${PROGDIR}/backend/zfsmksnap.sh "${DATASET}" "$SNAPNAME" "$COMMENT"
;;
listcron) require_root
View
6 src-sh/warden/bin/warden
@@ -302,11 +302,11 @@ help_zfsmksnap()
title
echo "Help zfsmksnap
-Create a new ZFS snapshot of a jail
+Create a new ZFS snapshot of a jail, with an optional comment
Usage:
- warden zfsmksnap <Jail>
+ warden zfsmksnap <Jail> <comment>
Example:
@@ -1075,7 +1075,7 @@ defaultrouter-ipv6) DEFAULTROUTER="${4}"
if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
set_warden_metadir
- ${PROGDIR}/scripts/backend/zfsmksnap.sh "${JAILNAME}"
+ ${PROGDIR}/scripts/backend/zfsmksnap.sh "${JAILNAME}" "$3"
;;
zfslistclone) require_root
View
2  src-sh/warden/scripts/backend/cronsnap.sh
@@ -53,7 +53,7 @@ do
fi
fi
if [ "$needSnap" = "1" ] ; then
- mkZFSSnap "${JAILDIR}"
+ mkZFSSnap "${JAILDIR}" "Automated Snapshot"
fi
# Do any pruning
View
13 src-sh/warden/scripts/backend/functions.sh
@@ -353,6 +353,10 @@ mkZFSSnap() {
rp=`getZFSRelativePath "$1"`
zdate=`date +%Y-%m-%d-%H-%M-%S`
zfs snapshot $tank${rp}@$zdate
+ # Do we have a comment to set?
+ if [ -n "$2" ] ; then
+ zfs set warden:comment="$2" ${tank}${rp}@${zdate}
+ fi
}
listZFSSnap() {
@@ -360,7 +364,14 @@ listZFSSnap() {
if [ $? -ne 0 ] ; then printerror "Not a ZFS volume: ${1}" ; fi
tank=`getZFSTank "$1"`
rp=`getZFSRelativePath "$1"`
- zfs list -t snapshot | grep -w "^${tank}${rp}" | cut -d '@' -f 2 | awk '{print $1}'
+
+ echo "Snapshot Comment"
+ echo "-----------------------------------------------"
+ for i in `zfs list -t snapshot | grep -w "^${tank}${rp}" | cut -d '@' -f 2 | awk '{print $1}'`
+ do
+ comment=`zfs get -o value warden:comment $i | grep -v "VALUE"`
+ echo "$i $comment"
+ done
}
listZFSClone() {
Please sign in to comment.
Something went wrong with that request. Please try again.