What a great list. Thanks for all the scripting help.
What I've got written at this point is the following, with a few obvious
notes:
1) note the wonderfully sloppy global variables. :)
2) the pgreps can certainly be internalized to the script for better
performance, and the */* construct in the first one should probably use
File::Find instead.
3) I'm only interested in the backups from one client, which greatly
speeds up this script. If I had to search multiple clients, I'd need to
change the %mediaids data structure because it's entirely possible that
two backups have the same timestamp (we have three libraries with multiple
drives -- it could happen).
4) It's a decent enough framework -- it prints the date of the backup
(taken from the filename of the header/filelist files) and the mediaID
that the fragment is on.
#!/usr/local/bin/perl -w
use strict;
use vars qw(
@ARGV $ARGC $DBDIR @result
$line $filename $date @fragments $fragment
$mediaid %mediaids
$key
);
$DBDIR="/usr/openv/netbackup/db/images/<client>";
if (!defined($ARGV[0])) {exit;}
@result=`/usr/local/bin/pgrep -l $ARGV[0] $DBDIR/*/*.f`;
foreach $line (@result) {
($filename,undef)=split(/:/,$line,2);
$filename=~s/\.f$//;
(undef,$date,undef)=split(/_/,$filename);
@fragments=`/usr/local/bin/pgrep ^FRAGMENT $filename`;
foreach $fragment (@fragments) {
(undef,undef,undef,undef,undef,undef,undef,undef,$mediaid,undef)=split(/
/,$fragment,10);
if (defined($mediaids{"$date"})) {$mediaids{"$date"}.=", $mediaid";}
else {$mediaids{"$date"}="$mediaid";}
}
}
print "Date: mediaid for product $ARGV[0]\n";
foreach $key (sort { $mediaids{$b} <=> $mediaids{$a} } (keys(%mediaids)))
{
print scalar localtime($key),": $mediaids{$key}\n";
}
Adam Levin, Senior Unix Systems Administrator | http://www.audible.com/
Audible, Inc.
Wayne, NJ, 07470 I'm wet! I'm hysterical, and I'm wet!
973-837-2797 I'm in pain, and I'm wet, and I'm still hysterical!
|