[PC-BSD Commits] r21630 - pcbsd/current/src-sh/warden/scripts/backend

svn at pcbsd.org svn at pcbsd.org
Fri Feb 22 14:20:27 PST 2013


Author: kris
Date: 2013-02-22 22:20:27 +0000 (Fri, 22 Feb 2013)
New Revision: 21630

Modified:
   pcbsd/current/src-sh/warden/scripts/backend/cronsnap.sh
Log:

Fix up the cron cleanup functionality in warden zfs snapshots



Modified: pcbsd/current/src-sh/warden/scripts/backend/cronsnap.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/cronsnap.sh	2013-02-22 16:13:46 UTC (rev 21629)
+++ pcbsd/current/src-sh/warden/scripts/backend/cronsnap.sh	2013-02-22 22:20:27 UTC (rev 21630)
@@ -31,7 +31,7 @@
   needSnap=0
   zdate=`date +%Y%m%d-%H%M%S`
   if [ "$CRONFREQ" = "daily" ] ; then
-     #echo "Checking for daily snapshots to ${jIP}..."
+     echo "Checking for daily snapshots to ${jIP}..."
      today=`date +%Y-%m-%d`
      lastsnap=`echo $lastsnap | cut -d '-' -f 1-3`
      if [ "$today" != "$lastsnap" ] ; then
@@ -52,19 +52,27 @@
      mkZFSSnap "${JDIR}/${jIP}"
   fi
 
+
   # Do any pruning
   num=0
-  for snap in `echo $snaps | sort -r`
+  echo "$snaps" | sort -g -r >/tmp/.wardensnaps.$$
+  while read snap
   do
-     cur="`echo $snap | cut -d '-' -f 1`" 
+     if [ "$CRONFREQ" = "daily" ] ; then
+        cur="`echo $snap | cut -d '-' -f 1-3`" 
+     else
+        cur="`echo $snap | cut -d '-' -f 1-4`" 
+     fi
      if [ "$cur" != "$prev" ] ; then
         num=`expr $num + 1`
         prev="$cur"
      fi
+     #echo "Checking $cur : Prev $prev : KEEPDAYS $CRONKEEPDAYS : NUM $num"
      if [ $num -gt $CRONKEEPDAYS ] ; then
         #echo "Pruning old snapshot: $snap"
         rmZFSSnap "${JDIR}/${jIP}" "$snap"
      fi
-  done
+  done < /tmp/.wardensnaps.$$
+  rm /tmp/.wardensnaps.$$
 done
 



More information about the Commits mailing list