Amanda-Users

Re: Tapes offsite

2005-09-11 11:12:08
Subject: Re: Tapes offsite
From: Jon LaBadie <jon AT jgcomp DOT com>
To: amanda-users AT amanda DOT org
Date: Sun, 11 Sep 2005 10:55:09 -0400
On Sun, Sep 11, 2005 at 06:45:45AM +0200, Jasper Aukes wrote:
> Hi,
> 
> I've been using Amanda for about 8 years now and never bothered to keep
> tapes offsite for several reasons.
> Recently I purchased a DDS5 deck with 30 tapes to be able to start saving
> tapes offsite every now and then.
> 
> To be able to tell what tapes I need to take, I wrote a small script.
> Perhaps it's usefull to some of you?
> 
> Please notice that it's under construction and it only considers level 0 and
> 1 dumps. I should enhance the script to also consider level 2 and perhaps
> even 3 or 4.
> 
> I'll be happy reading your comments on it.

The first comment is a question, what is your criteria for deciding a tape
needs to be taken offsite?  My quick experiment suggests it is a minimum of
back to the the most recent level 0 of every client encountered.

That criteria may be different for different sites.  For example, I try to
keep the most recent dumps onsite figuring they are the most likely to be
wanted for a "I deleted a file" type of recovery.  I'd love to get that
RAIT config working where it mirrors my tape changer and some vtapes.
Then I could leave the vtapes "onsite" and the physical tapes offsite.

It did need addition of support for extra levels for me to run it.  I have
no idea if my changes were complete, just sufficient for a sample run.
The changes I made were dupicating LevelOne() as LevelTwo and LevelThree
and adjusting PreHouseKeeping.

You might put some comments near the top about what parameters need to be
adjusted for local usage (location of perl, amadmin, config name, ...)

> 
> Kind regards,
> 
> Jasper Aukes

> #!/usr/bin/perl -w
> 
> use strict;
> my 
> ($AMADMIN,$CONFIG,$COMMAND,@output,$host,$filesystem,$level,$tape,$status,$lasthost,$lastfilesystem,$neednull,$needone,%tapes);
> 
> &Init;
> &Collect;
> &Report;
> 
> sub Init {
>       $AMADMIN = "/usr/sbin/amadmin";
>       $CONFIG = "thuis";
>       $COMMAND = "$AMADMIN $CONFIG find";
>       @output = `$COMMAND`;
>       die "Unable to run '$COMMAND'\nPlease run as user 'amanda' or 'root'" 
> if ($?);
> }
> 
> sub Collect {
>       while (@output) {
>               my $line = pop(@output);
>               chomp $line;
>               $line =~ s/\s+/ /g;
>               next unless ($line =~ '^20');
>               ($host,$filesystem,$level,$tape,$status) = (split 
> /\s/,$line)[1,2,3,4,6];
>               next unless ($status eq "OK");
>               &PreHouseKeeping;
>               &Select($tape) if Needed();
>               &PostHouseKeeping;
>       }
> }
> 
> sub PreHouseKeeping {
>       die "Unknown level ($level) found\n" unless (LevelOne() or LevelNull());
>       $lasthost = "" unless defined ($lasthost);
>       ResetLevels() if (NewHost() or NewFilesystem());
> }
> 
> sub LevelNull {
>       if ($level eq "0") {
>               $needone = 0;
>               return 1;
>       }
>       return 0;
> }
> 
> sub LevelOne {
>       return 1 if ($level eq "1");
>       return 0;
> }
> 
> sub ResetLevels {
>       $neednull = $needone = 1;
> }
> 
> sub NewHost {
>       return 1 if ($lasthost ne $host);
>       return 0;
> }
> 
> sub NewFilesystem {
>       return 1 if ($lastfilesystem ne $filesystem);
>       return 0;
> }
> 
> sub Select {
>       my $tape = "@_";
>       $tapes{$tape} = 1;
> }
> 
> sub Needed {
>       return 1 if (LevelNull() and $neednull);
>       return 1 if (LevelOne() and $needone);
>       return 0;
> }
> 
> sub PostHouseKeeping {
>       $neednull = 0 if LevelNull();
>       $needone = 0 if LevelOne();
>       $lasthost = $host;
>       $lastfilesystem = $filesystem;
> }
> 
> sub Report {
>       print "Need the following tapes:\n";
>       foreach (sort keys %tapes) {
>               print "$_\n";
>       }
> }

>>> End of included message <<<

-- 
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>