Veritas-bu

[Veritas-bu] Script question - regarding duplication

2000-10-31 15:28:23
Subject: [Veritas-bu] Script question - regarding duplication
From: Randy Dees rdees AT colltech DOT com
Date: Tue, 31 Oct 2000 15:28:23 -0500
And behold, egml5 spake these words on Mon, Oct 30, 2000 at 05:43:59PM -0500:
> I am looking for a command to output media id's 
> containing duplicates written during a specified time period.
> I would like the output to be in the form of a bare list
> of the media id much like the output of 
> 
> bpimagelist -media -idonly -hoursago 24
> 
> I am working on a session_notify script to 
> automate our duplication process which includes performing 
> bpexpdates on month-end and year-end duplicate backup media.  
> If I can get a list of media id's that contain duplicates during a 
> particular window of time - I will be able to then use them in the 
> script to automate our duplication process.

Here's what I am working on (It's obviously unfinished) for solving a similar
problem.  This code contains way too much that is hardcoded but might help you
or someone else.

Some assumptions I am working under:  

I have a single schedule that contains all the images that I want duplicated.
If you don't want to limit to a single schedule, remove "-sl $Schedule" from
$TapesOpts.

All of my duplicates are done to pools especially set up for duplicating into.

I want to remove the original tapes, not the duplicates.  The duplicates
remain onsite and are set as the primary copy with bpduplicate -npc.  This
ensures I only send verified media offsite.  If you want to send the
originals, change the 
"next TAPE if ($Dup_Pool =~" to 
"next TAPE if ($Dup_Pool !~"

I assume that the existance of a copy 2 for any copy 1 means I got a good copy
2.  My testing for this is done in the duplication script, not in this script
which is meant only to find the tapes to eject.

Output is not what you wanted, but is all done after "close TAPES" and you can
easily fix that.  

If you're trying to change the behavior of the thing, it may be worthwhile to
set $Bug_Output to 1, so that you can see what is going on.  Set it back to 0
for production use.

There's a test for $Robot_Type = TLD here that will ignore tapes that are not
in my robot.  If your robot type is not TLD, you probably need to change that
line.  

This script permits me to find tapes I want to eject and then verify that all
the images on each tape have been duplicated.  Therefore, any tape that is
ejected is actually safe to do so, even though I am keeping the duplicates and
not the originals.
___

#! /usr/bin/perl

# Set this token > 0 for debug output
$Bug_Output =   0;

$NbPath =               "/usr/openv/netbackup/bin";
$AdminPath =    "$NbPath/admincmd";
$BpImageList =  "$AdminPath/bpimagelist";
$BpImMedia =    "$AdminPath/bpimmedia";
$VmQuery =              "/usr/openv/volmgr/bin/vmquery";
$Grep =                 "/usr/local/bin/grep";

$Start_Date =   "9/01/00";
$End_Date =             "11/01/00";
$Schedule =             "Monthly_Archive";
$TapesOpts =    "-media -idonly -d $Start_Date -e $End_Date -sl $Schedule";
$PoolOpts =             "-bx";

# I like symmetry even if I am not going to use the $ImageOpts variable.  It's
# defined and could conceivably be used.
$ImagesOpts =   "";


# Turns out this probably doesn't need defined, but its not worth removing it. 
$Orig_Pool =    "Daily, NetApp, NetBackup";
$Dup_Pool =             "Tar_Dup, Dump_Dup";


open (TAPES,"$BpImageList $TapesOpts |");
# I had a nasty loop problem that adding the label allowed me to get around.
# Not strictly required anymore, but leave it in anyhow.
TAPE: while (<TAPES>) {
        chomp;
        $tape = $_;
        bug_out($tape);
        # What pool is the tape in
        open (POOL,"$VmQuery $PoolOpts -m $tape |");
        while (<POOL>) {
                # Discard all the cruft lines
                next unless $_ =~ /$tape/;
                chomp;
                # The 14th field of vmquery output is the pool name
                ($Tape_Lable,$Tape_Type,$Robot_Type,$Robot_Num,$slot_num,
                 $a,$a,$a,$a,$a,
                 $a,$a,$a,$pool[$tape]) = split;
        }
        close POOL;
        bug_out("$pool[$tape]");
        next TAPE if ($Dup_Pool =~ /$pool[$tape]/ );
        next TAPE if ($Robot_Type ne "TLD");
        open (IMAGES,"$BpImMedia $ImagesOpts -mediaid $tape |");
        while (<IMAGES>) {
                chomp;
                $line = $_;
                if ($line =~ /FRAG 2/) {
                        next if ($copy_OK);
                        ($a,$a,$fragnum,$other) = split /\s+/, $line;
                        bug_out("copy good");
                        $copy_OK = "true";
                }
                if ($line =~ /IMAGE/) {
                    if ($image && (! $copy_OK)) {
                                bug_out("$image is bad");
                                $bad_images[$tape] .= $image . " ";
                        }
                        $copy_OK = "";
                        ($a,$system,$b,$image,$class,$c,$Schedule_Name,$other) =
                                split /\s+/, $line;
                        bug_out($image);
                        # Now I have the backup ID name to use; I want to know 
if there is
                        # a copy 2 for this image.  
                }
        
        }
        close IMAGES;
        if (! $bad_images[$tape]) {
                $good_tapes .= $tape . " ";
        }
        else {
                $bad_tapes .= $tape . " ";
        }
}
close TAPES;

if ($bad_tapes) {
        @bad_tapes = split " ", $bad_tapes;
        foreach $tape (@bad_tapes) {
                print "Tape $tape has these images that still need copied:\n";
                @images = split " ", $bad_images[$tape];
                $Image_on_row=0;
                foreach $image (@images) {
                        print "$image   ";
                        $Image_on_row++;
                        if ($Image_on_row == 3) {
                                print "\n";
                                $Image_on_row=0;
                        }
                }
                if ($Image_on_row != 0) { print "\n"; }
        }
}

@eject_tapes = split " ", $good_tapes;
foreach $tape (@eject_tapes) {
        print "$tape is ready and should be sent offsite.\n";
}

exit 0;

sub bug_out {
        $Bug_Output || return 0;
        print @_;
        print "\n";
}

-- 
                        _                       _
    Randy Dees         |_| C o l l e c t i v e |_|    rdees AT colltech DOT com
 Pager:  800-946-4646  |_     technologies      _|     www.colltech.com
   Pin:  1433794        []                     []  "The Power of Many Minds"



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