Amanda-Users

Re: How could amflush NOT flush ? :o)

2003-08-12 16:23:43
Subject: Re: How could amflush NOT flush ? :o)
From: Jon LaBadie <jon AT jgcomp DOT com>
To: amanda-users AT amanda DOT org
Date: Wed, 23 Jul 2003 10:36:42 -0400
On Wed, Jul 23, 2003 at 03:53:13PM +0200, Nicolas Ecarnot wrote:
> Hi,
> 
> My Amanda setup keeps improving tests after tests and I still have so many 
> questions.
> Today is : How could I do to make automatic flushes (autoflush) but without 
> deleting the holding disk directories ?
> 
> What I'd like to have is this situation :
> - cron launches amdump
> - the autoflush option is set, so as to write datas on the holding disk AND 
> to tape
> - but to keep the last holding disk directory
> - Another cron would remove the (n-1) last hoslding disk directory
> 
> That way, I could restore the previous-day files directly from the holding 
> disk files, without having to go search my tapes. 
> 
> I first thought about a script that would launch amdump without the option 
> autoflush, then copy the last created directory, then launch amflush.
> But that copy is way too large for my not-so-small 120Go holding disk.
> 
> Have you any idea ?


Use links instead of copies.  You would have to keep looking for new
files and directories and as they appear, make a link to them.  The
reason this would work is that when amdump removes its file, the
second link to the data would remain and thus the data not removed.

You also would not want to link to them until they are renamed without
the ".tmp" extension.

Here is a possible script, totally untested and using my paths.

HoldDir=/u/dumps
AmandaDir=${HoldDir}/amanda
AmandaDupDir=${HoldDir}/amanda-dup
IntervalTime=60

# if you want the new directories to have specific permissions
# you may have to put in a umask setting, something like:
# "umask 077" to make the dirs "drwx------"

# Get to top of Amanda Tree
cd ${AmandaDir} || { # error processing if can't cd to holding dir
        # any notices, or mail, or ... you want
        # but we can't go on
        exit 1
}

while true      # endless loop
do
        find . -type f |        # locate all ordinary files
        grep -v '.tmp$' |       # eliminate the tmp files
        while read Dfile
        do
                # check if link already made
                # I'd prefer the -e option of new shells, but ...
                if [ -f ${AmandaDupDir}/${Dfile} ]
                then
                        continue        # nothing to do
                fi

                # split name into dir and file parts
                Ddir=`dirname ${Dfile} | sed 's,^\./,,'`
                Dname=`basename ${Dfile}`
                LinkDir=${AmandaDupDir}/${Ddir}
                LinkFile=${LinkDir}/${Dname}

                # make LinkDir if needed
                [ -d ${LinkDir} ] || mkdir ${LinkDir}
                        # should do error processing, but I'm lazy

                # link to dump file
                ln ${Dfile} ${LinkFile}
                        # ditto error processing
        done

        # sleep for a bit before doing all this again
        sleep ${IntervalTime}
done



Hope you find this interesting/useful/???

-- 
Jon H. LaBadie                  jon AT jgcomp DOT com
 JG Computing
 4455 Province Line Road        (609) 252-0159
 Princeton, NJ  08540-4322      (609) 683-7220 (fax)


<Prev in Thread] Current Thread [Next in Thread>