Changeset cca8f57


Ignore:
Timestamp:
05/13/14 09:26:11 (15 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, enter/10, releng/10.0.2, releng/10.0.3, releng/10.1, releng/10.1.1, releng/10.1.2
Children:
30cf8dd, de73897
Parents:
ee5baaa7
Message:

Add the ability for both Life-Preserver and Warden to set an optional
comment on snapshots at creation time

Location:
src-sh
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src-sh/lpreserver/backend/functions.sh

    re0264b3 rcca8f57  
    7171  zdate=`date +%Y-%m-%d-%H-%M-%S` 
    7272  zfs snapshot $flags ${1}@$2${zdate} >${CMDLOG} 2>${CMDLOG} 
     73 
     74  # Do we have a comment to set? 
     75  if [ -n "$3" ] ; then 
     76      zfs set lpreserver:comment="$3" ${1}@${2}${zdate} 
     77  fi 
     78 
    7379  return $? 
    7480} 
    7581 
    7682listZFSSnap() { 
    77   zfs list -d 1 -t snapshot | grep -e "^${1}@" | awk '{print $1}' 
     83  echo "Snapshot                                Comment" 
     84  echo "-----------------------------------------------" 
     85  for i in `zfs list -d 1 -t snapshot | grep -e "^${1}@" | awk '{print $1}'` 
     86  do 
     87     comment=`zfs get -o value lpreserver:comment $i | grep -v "VALUE"` 
     88     echo "$i           $comment" 
     89  done 
    7890} 
    7991 
  • src-sh/lpreserver/backend/runsnap.sh

    r1be462f rcca8f57  
    178178# Create the snapshot now with the "auto-" tag 
    179179echo_log "Creating snapshot on ${DATASET}" 
    180 mkZFSSnap "${DATASET}" "auto-" 
     180mkZFSSnap "${DATASET}" "auto-" "Automated Snapshot" 
    181181if [ $? -ne 0 ] ; then 
    182182  echo_log "ERROR: Failed creating snapshot on ${DATASET}" 
  • src-sh/lpreserver/backend/zfsmksnap.sh

    r9c74d02 rcca8f57  
    2323fi 
    2424 
     25COMMENT="$3" 
     26 
    2527# Make the snapshot now 
    2628snapStat=0 
    2729 
    2830echo_log "Creating snapshot on ${DATASET}" 
    29 mkZFSSnap "${DATASET}" "${SNAPNAME}" 
     31mkZFSSnap "${DATASET}" "${SNAPNAME}" "$COMMENT" 
    3032if [ $? -ne 0 ] ; then 
    3133  echo_log "ERROR: Failed creating snapshot on ${DATASET}" 
  • src-sh/lpreserver/lpreserver

    r9c74d02 rcca8f57  
    387387Usage: 
    388388 
    389   lpreserver mksnap <dataset> <snapshotname> 
     389  lpreserver mksnap <dataset> <snapshotname> <comment> 
    390390 
    391391Example: 
     
    395395  or 
    396396 
    397   lpreserver mksnap tank1/usr/home/kris mysnapshot 
     397  lpreserver mksnap tank1/usr/home/kris mysnapshot \"Added user bob\"  
    398398 
    399399NOTE: 
     
    497497         DATASET="$2" 
    498498         SNAPNAME="$3" 
    499          ${PROGDIR}/backend/zfsmksnap.sh "${DATASET}" "$SNAPNAME" 
     499         COMMENT="$4" 
     500         ${PROGDIR}/backend/zfsmksnap.sh "${DATASET}" "$SNAPNAME" "$COMMENT" 
    500501         ;; 
    501502 
  • src-sh/warden/bin/warden

    r4054989 rcca8f57  
    303303 echo "Help zfsmksnap 
    304304 
    305 Create a new ZFS snapshot of a jail 
    306  
    307 Usage: 
    308  
    309   warden zfsmksnap <Jail> 
     305Create a new ZFS snapshot of a jail, with an optional comment 
     306 
     307Usage: 
     308 
     309  warden zfsmksnap <Jail> <comment> 
    310310 
    311311Example: 
     
    10761076         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi 
    10771077         set_warden_metadir 
    1078          ${PROGDIR}/scripts/backend/zfsmksnap.sh "${JAILNAME}" 
     1078         ${PROGDIR}/scripts/backend/zfsmksnap.sh "${JAILNAME}" "$3" 
    10791079         ;; 
    10801080 
  • src-sh/warden/scripts/backend/cronsnap.sh

    r1620346 rcca8f57  
    5454  fi 
    5555  if [ "$needSnap" = "1" ] ; then 
    56      mkZFSSnap "${JAILDIR}" 
     56     mkZFSSnap "${JAILDIR}" "Automated Snapshot" 
    5757  fi 
    5858 
  • src-sh/warden/scripts/backend/functions.sh

    rc2b5aad rcca8f57  
    354354  zdate=`date +%Y-%m-%d-%H-%M-%S` 
    355355  zfs snapshot $tank${rp}@$zdate 
     356  # Do we have a comment to set? 
     357  if [ -n "$2" ] ; then 
     358      zfs set warden:comment="$2" ${tank}${rp}@${zdate} 
     359  fi 
    356360} 
    357361 
     
    361365  tank=`getZFSTank "$1"` 
    362366  rp=`getZFSRelativePath "$1"` 
    363   zfs list -t snapshot | grep -w "^${tank}${rp}" | cut -d '@' -f 2 | awk '{print $1}' 
     367 
     368  echo "Snapshot                                Comment" 
     369  echo "-----------------------------------------------" 
     370  for i in `zfs list -t snapshot | grep -w "^${tank}${rp}" | cut -d '@' -f 2 | awk '{print $1}'` 
     371  do 
     372     comment=`zfs get -o value warden:comment $i | grep -v "VALUE"` 
     373     echo "$i           $comment" 
     374  done 
    364375} 
    365376 
Note: See TracChangeset for help on using the changeset viewer.