Veritas-bu

Re: [Veritas-bu] Last execution time of a backup policy

2008-01-24 21:06:04
Subject: Re: [Veritas-bu] Last execution time of a backup policy
From: A Darren Dunham <ddunham AT taos DOT com>
To: Veritas-bu AT mailman.eng.auburn DOT edu
Date: Fri, 25 Jan 2008 01:52:15 +0000
On Thu, Jan 24, 2008 at 10:21:44AM -0600, Shyam Hazari wrote:
> I inherited a messy netbackup environment(5.1 MP5). There is a tonne of
> inactive policies(more than hundred). Before I nuke them I would like to
> find out when was the last time it was executed. Any easy way to find this ?
> I can look at the catalog one by one, but it will take forever.

Seemed interesting.  I wrote a quick perl script to do this.  Run it and
give it a start date on the command line.  This is how far back it will
look through the catalog.  (If you compress your catalog, going back a
long way will uncompress it and make it take a long time).  The only
thing it executes is 'bppllist -allpolices -l' and
'bpimagelist -l -d <date>'.  

It grabs the policies to find which are currently active, and it dumps
the catalog to find old backups.  

Now realize, a particular policy may have any number of clients and any
number of items in the filelist.  This program doesn't care about any of
that.  If even *one* catalog entry for that policy is found, it counts.
It records the last date it finds and prints it out.

Items with a "X" are from polices that don't exist, 'i' marks inactive
polices, and the rest are active policies.

I hope it works for you...

#!/usr/bin/perl
use strict;
use warnings;
use POSIX ();

die "Usage: $0 mm/dd/yyyy    Date marks start of catalog search\n"
  unless (@ARGV == 1);
my $start_date = shift;

# Gather current status of policies
my %policies;
my $cmd = '/usr/openv/netbackup/bin/admincmd/bppllist';
my $args = '-allpolicies -l';
open (my $policy_fh, '-|', "$cmd $args") or
  die "$0: Could not open pipe from $cmd. $!\n";

my $class;
while (my $line = <$policy_fh>)
  {
    if ($line =~ /^CLASS (\S+) /)
      { $class = $1; }
    elsif ($line =~ /^INFO/)
      {
        my @line = split (' ', $line);
        if ($line[11])
          { $policies{$class}{'active'} = 0; }
        else
          { $policies{$class}{'active'} = 1; }
      }
  }    
close $policy_fh;

# read the images
$cmd = '/usr/openv/netbackup/bin/admincmd/bpimagelist';
$args = "-l -d $start_date";
open (my $images, '-|', "$cmd $args 2>/dev/null") or
  die "$0: Could not open pipe from $cmd. $!\n";

while (my $line = <$images>)
  {
    next unless $line =~ /^IMAGE/;
    my @info = split ' ', $line;
    my ($policy_name, $time) = @info[6,13];

    if (!exists $policies{$policy_name}{'last'} or
        $time > $policies{$policy_name}{'last'})
      { $policies{$policy_name}{'last'} = $time; }
  }
close $images;

foreach my $policy (sort keys %policies)
  {
    my $active;
    if (! exists $policies{$policy}{'active'})
      { $active = "X"; }
    elsif ($policies{$policy}{'active'} == 0)
      { $active = "i"; }
    else
      { $active = " "; }
    my $time = '   never  ';
    if (exists $policies{$policy}{'last'})
      { $time = POSIX::strftime ("%Y-%m-%d",
                                 localtime ($policies{$policy}{'last'}))}
    print "$time $active $policy\n";
  }
__END__


-- 
Darren Dunham                                           ddunham AT taos DOT com
Senior Technical Consultant         TAOS            http://www.taos.com/
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >
_______________________________________________
Veritas-bu maillist  -  Veritas-bu AT mailman.eng.auburn DOT edu
http://mailman.eng.auburn.edu/mailman/listinfo/veritas-bu