Veritas-bu

[Veritas-bu] Exclude lists on Unix clients

2011-12-06 08:29:16
Subject: [Veritas-bu] Exclude lists on Unix clients
From: pwhelan0610 <nbu-forum AT backupcentral DOT com>
To: VERITAS-BU AT MAILMAN.ENG.AUBURN DOT EDU
Date: Tue, 06 Dec 2011 05:28:06 -0800
Ok, here it is. You might also notice that it is written to run on a *NIX 
master, can be fixed if necessary.
If there are any problems let me know and I will attempt to fix them.
#=================== Begin Code ==========================

#!/usr/bin/perl

use strict;
use warnings;
use Getopt::Std;


our $opt_d = 0;
our $opt_v = 0;

getopt ('dv');

our $debug = $opt_d;
our $check_version = $opt_v;

my $uname = `uname -n`;
chomp $uname;

# Desiginate where to write the in/exclude files (must be fully qualified path)
our $PWD = $ENV{PWD};
our $output_dir = "$PWD/EI_${uname}";
if ( ! -d $output_dir ) { mkdir $output_dir }


# Location of bp.... commands
our $nbadmin = "/usr/openv/netbackup/bin/admincmd";

# Generate a list of policies
our @policy_list = `$nbadmin/bppllist`;

# Used the get output of the bpgetconfig command. Only need for debut purposes
our @status = ();


foreach my $policy (@policy_list) {
        chomp $policy;

        # Get the individual policy information
        my @policy = `$nbadmin/bppllist $policy -l`;

        # Extract the info line
        my @info = grep /^INFO /, @policy;

        # If the policy type is not standard, ignore
        if ( (split /\s+/, $info[0])[1] != 0 ) { next }

        # If the policy is inactive, ignore
        if ( (split /\s+/, $info[0])[11] != 0 ) { next }

        # Pull out the clients for this policy and then keep only the client 
names
        my @clients = grep /^CLIENT /, @policy;
        @clients = map { (split /\s+/, $_)[1]} @clients;

        # Pull out the schedules for this policy and then keep only the 
schedule names
        my @schedules = grep /^SCHED /,@policy;
        @schedules = map { (split /\s+/, $_)[1]} @schedules;

        # Now for each client
        foreach my $client (@clients) {

                if ($debug != 0) { print STDERR "$client $policy\n"; }

                # Be sure the client is at leas pingable otherewise the 
bpgetconfig command will take a long time to fail
                system("ping -c 1 -W 5 $client > /dev/null 2>&1");
                if ($? != 0  ) { print STDERR "$client not pingable\n"; next }

                # If version check is set
                if ($check_version) { print STDERR `bpgetconfig -t -L -g 
$client` }

                # get, if any, the basic include and/or exclude files. (i.e. 
/usr/openv/netbackup/exclude_list or include_list)
                @status = `$nbadmin/bpgetconfig -e 
\"/$output_dir/exclude.$client.basic\" \"$client\"`;
                if ($? != 0 && $debug != 0  ) { print STDERR "$client 
bpgetconfig -exclude no policy failed with $?\n @status" }
                @status = `$nbadmin/bpgetconfig -i 
\"/$output_dir/include.$client.basic\" \"$client\"`;
                if ($? != 0  && $debug != 0 ) { print STDERR "$client 
bpgetconfig -include no policy failed with $?\n @status" }

                # get, if any, the policy include and/or exclude files. (i.e. 
/usr/openv/netbackup/exclude_list.policy or include_list.policy)
                @status = `$nbadmin/bpgetconfig -e 
\"/$output_dir/exclude.$policy.$client\" \"$client\" \"$policy\"`;
                if ($? != 0 && $debug != 0  ) { print STDERR "$client 
bpgetconfig -exclude policy only failed with $?\n @status" }
                @status = `$nbadmin/bpgetconfig -i 
\"/$output_dir/include.$policy.$client\" \"$client\" \"$policy\"`;
                if ($? != 0 && $debug != 0  ) { print STDERR "$client 
bpgetconfig -include policy only failed with $?\n @status" }

                # Now for each schedule in the policy (i.e. 
/usr/openv/netbackup/exclude.policy.schedule=
                foreach my $schedule (@schedules) {
                        if ($debug != 0) { print STDERR "$client $policy 
$schedule\n"; }
                        @status = `$nbadmin/bpgetconfig -e 
\"/$output_dir/exclude.$policy.$client.$schedule\" \"$client\" \"$policy\" 
\"$schedule\"`;
                        if ($? != 0 && $debug != 0  ) { print STDERR "$client 
bpgetconfig -exclude with policy and schedule failed with $?\n @status" }
                        @status = `$nbadmin/bpgetconfig -i 
\"/$output_dir/include.$policy.$client.$schedule\" \"$client\" \"$policy\" 
\"$schedule\"`;
                        if ($? != 0 && $debug != 0  ) { print STDERR "$client 
bpgetconfig -include with policy and schedule failed with $?\n @status" }
                }
        }

        # If any of the bpgetconfigs work there ouput will be in the file name 
following the -e or -i
}

exit;
#====================== End of code ======================

Enjoy!

Regards,

Patrick

+----------------------------------------------------------------------
|This was sent by netbackup AT whelan-consulting.co DOT uk via Backup Central.
|Forward SPAM to abuse AT backupcentral DOT com.
+----------------------------------------------------------------------


_______________________________________________
Veritas-bu maillist  -  Veritas-bu AT mailman.eng.auburn DOT edu
http://mailman.eng.auburn.edu/mailman/listinfo/veritas-bu