cancel
Showing results for 
Search instead for 
Did you mean: 

Counting scratch tapes outside of library

Charles_Morra1
Level 3
I want to generate a report on scratch tapes that are _not_ in the library. This is used by the operators so they know what tapes they can take from off-site storage during scheduled tape rotation.

I thought I had it covered with
D:\VERITAS\NetBackup\bin\goodies\available_media.cmd | find "AVAILABLE" | find "NONE" | find "HCART2" > scratch_tapes_not_in_robot.log

However, I have also implemented a procedure where I rotate three tapes for catalog backup. One catalag tape is always kept outside the library, in a specially labeled container. In case of a total loss of the entire datacenter with the NBU Master, I can do a bprecover from this tape.
The other two tapes are kept in the library and the catalog backup is using these two tapes alternatively.

The tape kept outside the library is by NetBackup marked AVAILABLE, which I assume is ok since as far as NetBackup is concerned, I've pulled that tape out of the two-tape rotation for Catalog Backup. The only time (never hopefully) I'll read the tape is in case I need to restore the catalog and the library with all the tape is also lost.

The tape is still in the NetBackup pool though.

The above script lists all tapes not in the robot, with hcart2 media type and AVAILABLE. Of course, those criteria also apply to the third catalog tape.

How can I make a report with all scratch media outside the library?
1 REPLY 1

trickykid
Level 3
Here is a handy perl script you could probably hack around with to work on Windows, etc, I use that reports all existing blank tapes in the library and the tapes that are blank outside of the library in the scratch pool.

----------------------------------------------------------------
#!/usr/bin/perl -I /sysadmin/perllib

use nbu_db;
use Getopt::Long;
use strict;
use vars qw($showblanks $shuffle $result $db $volume $id %tapes @out_blank_LTO1 @out_blank_LTO2 @out_willexpire @in_willexpire @in_blank_LTO1 @in_blank_
LTO2 @pull_offsite @catalog_offsites @full_can_pull @in_blank);
my $showblanks=0;
my $shuffle=1;
my $result=GetOptions("blank"=> \$ showblanks,
"shuffle"=> \$shuffle);

my $db=nbu_db->new();

my $expiration_age_days = shift || 7;
my $expiration_age_seconds = ($expiration_age_days * 60 * 60 * 24);
my $need_blanks=0;
my @out_blank_LTO1;
my @out_blank_LTO2;
my @out_willexpire;
my @in_willexpired;
my @in_blank_LTO1;
my @in_blank_LTO2;
my @pull_offsite;
my @catalog_offsites;

foreach $id ($db->volumes())
{
$volume=$db->vol_byID($id);
if($volume->{volume_group} eq "---") # not in robot
{
if($volume->{volume_pool} eq "Scratch") #is blank
{
if($volume->{media_type} eq "HCART")
{
unshift(@out_blank_LTO1,$volume->{mediaID});
}
else
{
unshift(@out_blank_LTO2,$volume->{mediaID});
}
}
elsif($volume->{expiration_time} < (time() + $expiration_age_seconds))
{
unshift(@out_willexpire,$volume->{mediaID});
}
if($volume->{volume_pool} eq "CatalogOffsite")
{
unshift(@catalog_offsites,$volume->{mediaID});
}
}
else #in robot
{
$volume=$db->vol_byID($id);
if($volume->{robot_number} eq "0")
{
if($volume->{volume_pool} eq "Scratch") #is blank
{
if($volume->{media_type} eq "HCART")
{
unshift(@in_blank_LTO1,$volume->{mediaID});
}
else
{
unshift(@in_blank_LTO2,$volume->{mediaID});
}
}
elsif($volume->{expiration_time} < (time() + $expiration_age_seconds))
{
unshift(@in_willexpire,$volume->{mediaID});
}
if($volume->{volume_pool}=~/Offsite/)
{
unshift(@pull_offsite,$volume->{mediaID});
}
if($volume->{volume_pool} eq "CatalogOffsite")
{
unshift(@catalog_offsites,$volume->{mediaID});
}
if($volume->{status}==8 and $volume->{media_type} eq "HCART"
and $volume->{lastupdated_time} < time()-14*86400) #full for 2 weeks or more
{
unshift(@full_can_pull,$volume->{mediaID});
}
}
}
}

#sort stuff
@out_blank_LTO1=sort @out_blank_LTO1;
@out_blank_LTO2=sort @out_blank_LTO2;
@in_blank_LTO1=sort @in_blank_LTO1;
@in_blank_LTO2=sort @in_blank_LTO2;
@full_can_pull=sort byexpiry @full_can_pull;

if($showblanks==1)
{
showblanks();
exit;
}

#print scalar @in_blank_LTO1, "\tblank LTO1 tapes in library\n";
if(scalar @in_blank_LTO1 > 0)
{
print "Blank LTO1 tapes in library\n====================================\n";
print join(', ',@in_blank_LTO1),"\n\n";
}
#print scalar @in_blank_LTO2, "\tblank LTO2 tapes in library\n";
if(scalar @in_blank_LTO2 > 0)
{
print "Blank LTO2 tapes in library\n====================================\n";
print join(', ',@in_blank_LTO2),"\n\n";
}
#print scalar @out_blank_LTO1, "\tblank LTO1 tapes out of library\n";
if(scalar @out_blank_LTO1 > 0)
{
print "Blank LTO1 tapes out of library\n====================================\n";
print join(', ',@out_blank_LTO1),"\n\n";
}
#print scalar @out_blank_LTO2, "\tblank LTO2 tapes out of library\n";
if(scalar @out_blank_LTO2 > 0)
{
print "Blank LTO2 tapes out of library\n====================================\n";
print join(', ',@in_blank_LTO2),"\n\n";
}
#print scalar @full_can_pull, "\tfull tapes that can be removed from the library\n";
if(scalar @full_can_pull > 0)
{
print "Tapes that can be pulled to make room in library\n====================================\n";
print join(', ',@full_can_pull),"\n\n";
}

print scalar @pull_offsite+1," tapes being ejected for offsites\n\n";

$need_blanks=2*(scalar @catalog_offsites);
$need_blanks=$need_blanks-(scalar @in_blank)-(scalar @in_willexpire);

print "need $need_blanks more blanks in library\n";

sub byexpiry
{
$tapes{$b}{expiration_time} <=> $tapes{$a}{expiration_time};
}
sub showblanks
{
print "Blank tapes\n\nVolume ID\t\tVolume Group\n";
print "============================================\n";

foreach $id (@out_blank_LTO1,@out_blank_LTO2)
{
print "$id\t\t\t".$db->vol_byID($id)->{volume_group}."\n";
}
}

Message was edited by:
trickykid

I placed spaces between the $ and s's which were causing smilies to show up. :)Sorry, thought it was the $ and s's.. made spaces between the > and \