[Dirvish] Expire Rules

Richard Geoffrion dirvish at rain4us.net
Thu Dec 29 19:03:23 UTC 2005


Paul Slootman wrote:

 >On Wed 30 Nov 2005, Zachary Fortna wrote:
 >
 >>I am starting to run out of room on my dirvish volume and I'm wondering
 >>what the easiest way of cleaning it up is.
 >
 >
 >I just remove the image directory; that's basically the same thing
 >that dirvish-expire does. Just don't remove the last valid image
 >(dirvish-expire checks for that :-)
 >

I JUST had this same issue.  I didn't know how I wanted to set my expire 
times when I first setup the system.  On one hand, I wanted to keep as 
many backups as possible...but on the other hand, I couldn't afford to 
keep lots of  'BIG' backups.

Now that I've reached drive capacity, I can better understand how / when 
to set my expires.

I ran something at the command line to expire a slew of images...but 
then I forgot what I did.  How frustrating is that!?!  So when it came 
time again..I decided to write a script to do it.   Now..this is almost 
my first 'by myself' bash script..so forgive any crudeness you may see.  
One day I hope to implement the guts of this script into the 'style' of 
the other dirvish scripts so that one can specify a --vault parameter 
rather than having to sit in the actual vault itself.

I called the script 'dirvish-makeitexpire' and it will expire images 
based on um...parameters/wild-cards.   There is one 
assumption/requirement therefore there is one limitation of this 
script.  The limitation is that the code below expects(therefore 
requires) the DATE format for the images to be in the format %Y-%m-%d.  
I use this formatting to evaulate month-end backups.  The script is 
hard-coded to skip the manual expiration of month end backups.  Edit the 
script as needed to suit your needs. 

I'll go post this on my dirvish-example page. (which needs updating badly!)


As always, exercise caution with your data.

-------------

#!/bin/bash
#*********************************************************
#* Manually set dirvish vaults to expire.                *
#*                                                       *
#* Requires image format be set to use %Y-%m-%d          *
#* Set vault expire time to expire 'last year'           *
#* (Will not expire backups on the first day of month)   *
#* Created 2005-12-23 - RichardG                         *
#*********************************************************

#*********************************************************
# Make sure there is a paramater
#*********************************************************

if [ "$1" = "" ] ; then
    echo "Oops, I need a parameter.  What do you want to expire"
    echo "example:  $0 \*          #Expire all dirvish backups"
    echo "          $0 2005-10*  #Expire only October 2005 backups"
    exit
fi

    #*********************************************************
    # Check to make sure that we are IN a vault directory
    #*********************************************************
 
    if [ ! -f dirvish/default.conf ] ; then
        echo "I can't seem to find images.  This does not appear"
        echo "to be a dirvish vault. Please run this from inside"
        echo "a vault directory."
        exit
    fi

#*********************************************************
# Begin cycling through all of the directories given in
# the parameter on the command line in search of summary
# files.
#*********************************************************

for CYCLE in $@ ; do

 
    #*********************************************************
    # Cut bytes 9 and 10 out of the CYCLE string and assign
    # them to string CYCLEDATE. (NOTE: this needs to be
    # changed so that the directory date is evaluated, not the
    # directory (image) name)
    # Change the cut bytes below if you don't use image
    # format %Y-%m-%d
    #*********************************************************

    CYCLEDATE=`echo $CYCLE | cut -b 9-10`

    #*********************************************************
    # If the CYCLE evaluated is the first of a month. end this
    # CYCLE.
    #*********************************************************
    if [ "$CYCLEDATE" = "01" ] ; then
        echo "Skipping $CYCLE because it's a monthly"
        continue     #Skip to the next instance of CYCLE
    fi


    #*********************************************************
    # If the current CYCLE has a summary file, evaluate it
    # and pull out the current expire year
    #*********************************************************

    if [ -f $CYCLE/summary ] ; then
     
        #*********************************************************
        # Grab the current expire year, calculate new expire year
        #*********************************************************
        ORGYEAR=`grep Expire $CYCLE/summary | cut -f5 -d\ |cut -b 1-4`
        NEWYEAR=$ORGYEAR
        NEWYEAR=$[ NEWYEAR = $NEWYEAR - 1 ]
     
        #*********************************************************
        # Replace the ORGYEAR with NEWYEAR in the summary file
        #*********************************************************
        sed s/\=\=\ $ORGYEAR/\=\=\ $NEWYEAR/g < $CYCLE/summary > \
     $CYCLE/summary.new
        mv $CYCLE/summary.new $CYCLE/summary
        echo "$CYCLE has been set to expire."
    fi

done





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dirvish.org/pipermail/dirvish/attachments/20051229/b65bcee2/attachment.htm>


More information about the Dirvish mailing list