Deactivating Netbackup policies from the command line

Written by:

There may be a time to where you want to disable all netbackup policies from within a script or from the command line. I do this when I am performing some maintenance on the NBU server. A quick and dirty way is to run the following bit:

UNIX Server:

for i in /usr/openv/netbackup/bin/admincmd/bppllist
do
echo $i
/usr/openv/netbackup/bin/admincmd/bpplinfo $i -modify -inactive
done

If you would like something a little more robust. Try the code below. Running it with out any parameters will just go thru a list showing you want would be disabled. Running it with the parameter “run” will actually perform the disabling of the Active Netbackup policies.



#!/usr/bin/perl

if ( $ARGV[0] eq "run" ) {
$doit = 1;
print "FULL Run...\n";
} else {
$doit = 0;
print "Dry Run...\n";
print "Press to deactivate ALL Netbackup Policies";
$ans = ;
}

open(LOGFILE, "> /var/tmp/disable_policy.log") || die "Can't open /var/tmp/disable_policy.log \n";

open(BPPLLIST, "/usr/openv/netbackup/bin/admincmd/bppllist |") || die "Can't run bppllist command\n";
while () {
chomp;
$policy = $_;
$bpplinfocmd = "/usr/openv/netbackup/bin/admincmd/bpplinfo $policy -L ";

# print "Checking $policy\n";
open(BPPLINFO, "$bpplinfocmd |") || die "Can't run $bpplinfocmd\n";
$rc = $?;
if ($rc <= 20) {
$bpplinfo = '';
while () {
if (/^Active:/) {
chomp;
$bpplinfo = $_;
}
}
$bpplinfo =~ s/\s+//;
$bpplinfo =~ s/\t*//;
@line = split(":", $bpplinfo);
if ($line[1] =~ m/yes/i) {
if ( $doit == 1 ) {
`/usr/openv/netbackup/bin/admincmd/bpplinfo $policy -modify -inactive`;
}
print "$policy set inactive\n";
print LOGFILE "$policy set inactive\n";
} else {
print "Already inactive $policy\n";
print LOGFILE "Already inactive $policy\n";
}
}
close(BPPLINFO);
}
close(BPPLLIST);
close(LOGFILE);
print "\nLog file: /var/tmp/disable_policy.log\n";

Enjoy

Deactivating Netbackup policies from the command line
0 votes, 0.00 avg. rating (0% score)

Leave a Reply