Changeset 583ccad


Ignore:
Timestamp:
07/30/13 07:41:54 (13 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2
Children:
c2bfe2e
Parents:
2a9627a
Message:

Update lpreserver backend, should do recursive snaps / cleanup properly now

Location:
src-sh/lpreserver
Files:
3 edited

Legend:

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

    rc684936 r583ccad  
    1313DBDIR="/var/db/lpreserver" 
    1414 
     15#Set our Options 
     16setOpts() { 
     17  if [ -e "${DBDIR}/recursive-off" ] ; then 
     18    export RECURMODE="OFF" 
     19  else 
     20    export RECURMODE="ON" 
     21  fi 
     22 
     23  if [ -e "${DBDIR}/emaillevel" ] ; then 
     24    export EMAILMODE="`cat ${DBDIR}/emaillevel`" 
     25  fi 
     26 
     27  case $EMAILMODE in 
     28      ALL|WARN|ERROR) ;; 
     29        *) export EMAILMODE="WARN";; 
     30  esac 
     31 
     32  if [ -e "${DBDIR}/emails" ] ; then 
     33    export EMAILADDY="`cat ${DBDIR}/emails`" 
     34  fi 
     35 
     36 
     37} 
     38setOpts 
     39 
     40 
    1541# Check if a directory is mounted 
    1642isDirMounted() { 
     
    2046 
    2147mkZFSSnap() { 
     48  if [ "$RECURMODE" = "ON" ] ; then 
     49     flags="-r" 
     50  else 
     51     flags="-r" 
     52  fi 
    2253  zdate=`date +%Y-%m-%d-%H-%M-%S` 
    23   zfs snapshot ${1}@$2${zdate} 
     54  zfs snapshot $flags ${1}@$2${zdate} 
    2455} 
    2556 
     
    3061rmZFSSnap() { 
    3162  `zfs list -t snapshot | grep -q "^$1@$2 "` || exit_err "No such snapshot!" 
    32   zfs destroy ${1}@${2} 
     63  if [ "$RECURMODE" = "ON" ] ; then 
     64     flags="-r" 
     65  else 
     66     flags="-r" 
     67  fi 
     68  zfs destroy -r ${1}@${2} 
    3369  return $? 
    3470} 
  • src-sh/lpreserver/backend/runsnap.sh

    rc684936 r583ccad  
    1717fi 
    1818 
    19  
     19# Create the snapshot now with the "auto-" tag 
    2020mkZFSSnap "${DATASET}" "auto-" 
    2121 
     22# Get our list of snaps 
    2223snaps=$(snaplist "${DATASET}") 
    23  
    24 # Do any pruning 
    25 num=0 
    2624 
    2725# Reverse the list 
     
    3129done 
    3230 
     31# Do any pruning 
     32num=0 
    3333for snap in $rSnaps 
    3434do 
     
    3636   # made specifically 
    3737   cur="`echo $snap | cut -d '-' -f 1`"  
    38    if [ "$cur" != "auto" -a "$cur" != "auto-" ] ; then 
     38   if [ "$cur" != "auto" ] ; then 
    3939     continue; 
    4040   fi 
  • src-sh/lpreserver/lpreserver

    rc684936 r583ccad  
    4545 
    4646cat<<__EOF__ 
    47      mksnap - Create a ZFS snapshot of a jail  
    48    listsnap - List snapshots of a dataset 
     47     mksnap - Create a ZFS snapshot of a zpool/dataset 
     48   listsnap - List snapshots of a zpool/dataset 
    4949   cronsnap - Schedule snapshot creation via cron 
    50  revertsnap - Revert dataset to a snapshot 
     50 revertsnap - Revert zpool/dataset to a snapshot 
    5151     rmsnap - Remove a snapshot 
    5252__EOF__ 
     
    7171  emailopts - (ALL/WARN/ERROR)  
    7272                  ALL - Send mail for every snapshot, plus warnings and errors 
    73                  WARN - Send mail for warnings (such as low disk space) and errors 
     73                 WARN - Send mail for warnings and errors (Default) 
    7474                ERROR - Send mail for errors only 
     75 
     76  recursive - (ON/OFF)  
     77                   ON - Will create / destroy snapshots recursively, for all children of 
     78                        a target zpool/dataset. (Default) 
     79                  OFF - Will only create / destroy snapshots on the specified dataset.   
    7580 
    7681Example: 
     
    181186 
    182187  lpreserver rmsnap tank1/usr/home/kris 20130729-140510 
     188 
     189NOTE: 
     190By default snapshots are recursive and will remove snapshots 
     191of all children datasets automatically. To change this use: 
     192 
     193# lpreserver set recursive off 
    183194" 
    184195}; 
     
    199210 
    200211  lupdate mksnap tank1/usr/home/kris 
     212 
     213NOTE: 
     214By default snapshots are recursive and will create snapshots 
     215of all children datasets automatically. To change this use: 
     216 
     217# lpreserver set recursive off 
    201218" 
    202219}; 
Note: See TracChangeset for help on using the changeset viewer.