Veritas-bu

[Veritas-bu] bpgp ?

2006-08-16 10:34:35
Subject: [Veritas-bu] bpgp ?
From: david.clooney at bankofamerica.com (Clooney, David)
Date: Wed, 16 Aug 2006 15:34:35 +0100
 Thanks Chris

What I have done is incorporated bpdir by client, identified the various
files needed and the bpgp from client , all has worked out fine.

Regards 

D

-----Original Message-----
From: veritas-bu-bounces at mailman.eng.auburn.edu
[mailto:veritas-bu-bounces at mailman.eng.auburn.edu] On Behalf Of
Christopher Jay Manders
Sent: 15 August 2006 18:00
Cc: veritas-bu at mailman.eng.auburn.edu
Subject: Re: [Veritas-bu] bpgp ?

Hi!

Some thoughts, since we do this. We use a bpdir PERL wrapper to get all
of the files in a particular directory every day.
Then foreach thru to get those files. We do this daily, since we have
users that change config things and break 'em. This way we have evidence
without backing up those files....

Note the snippet below is basically what we use. You will need to tweek,
probably, and it does require a few CPAN thingies if you want the whole
thing. Basically, though, you will want to look at the GoGetFiles
function (at the bottom) to see how we loop using bpdir and then use
that output to grab the files....

Can be made to work for Winders and *nixes...

Hope it is useful...

Cheers!

--Chris

---------------------------------------------------
Example PERL wrapper to bpdir and bpgp:


## USE AT YOUR OWN RISK!!!!
#!/usr/bin/perl

  $|=1;
  use Date::Calc::Today()
  use Socket;

   my ($year,$month,$day) = Today();

   ## Make our right year.
   my $year = $year - 2000;

   if( $year < 10 )   {
      $year = "0" . $year;
   }

   if( $month < 10 )   {
      $month = "0" . $month;
   }

   if( $day < 10 )   {
      $day = "0" . $day;
   }

##
## Configurables
##
$mpath="/FILES/monitor";
$BPPath = "/usr/openv/netbackup";
$path="/FILES/monitor/$year/$month/$day";
`mkdir -p /FILES/monitor/$year/$month/$day`;
@bpclients = `$BPPath/bin/admincmd/bpclclients | tail +3 | awk \'{print
\$3}\'`;

  ## Check each client and get files if available.
  foreach my $Client ( @bpclients )
  {
     if( ! $Client ){ next; }
     chomp( $Client);
     print  "===========================================\n";
     ##
     print  "Checking Client Name: $Client\n";

     ## If PINGs and BPDIRs
     if(! &Pings( $Client ) )     {
        print  "$Client: NO ping.\n";
        next;
     }     elsif(! &BPListen( $Client ))     {
        print  "$Client: NO LISTEN.\n";
        next;
     }     else     {
       print  "$Client: Getting files\n";
       chomp( $Client);
       &GoGetFiles( $Client );
     }
           print  "===========================================\n";
   }


sub Pings
{
   my( $client ) = @_;
   #print "Attempting to ping: $client.\n";
   my @ping = `/usr/sbin/ping $client 2>&1`;
   if( grep( /alive/, @ping ) )
   { return 1; }else{ return 0; }
}

sub BPListen
{
  my( $host ) = @_;
  my $address;
  #print "Running with $host";

  my $res   = Net::DNS::Resolver->new;
  my $query = $res->search("$host");
  #print "Query for $host is set for DNS";

  if ($query)  {
    foreach my $rr ($query->answer)    {
       next unless $rr->type eq "A";
       #print $rr->address, "\n";
       $address = $rr->address;
    }
  }
  if( $host =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/ )  {
     $address = $host;
  }
  #print "$address\n";
  $addr=pack 'C4',split /\./,$address;
  $proto=getprotobyname 'tcp';
  socket SOCK, PF_INET, SOCK_STREAM,$proto;
  #print "Connect to socket";

  if (connect SOCK, sockaddr_in(13782,$addr)) {
    close SOCK;
    return 1;
  }
  else {
    close SOCK;
    return 0;
  }
}


sub BPDirs
{
  my ($Client ) = @_;

   my( $Client ) = @_;

   my @bpdir = `$BPPath/bin/admincmd/bpdir -M $Client /`;

   my @bpdirdata = grep "/", @bpdir;
   if( @bpdirdata) {
      return 1;
   }else{
      return 0;
   }
}

#&MakeDirectory($path, $Client);
sub MakeDirectory
{
  my($path, $Client) = @_;

  if(! -d "$path/$Client" )
  {
        `mkdir $path/$Client` ;
       `chmod 0755 $path/$Client`;
  }
  return;
}




##--------------------------------------------------------
## Go and get the remote client's config and dump to files.
## MUST ping to get this far...
## AND, MUST be able to BPDIR...
sub GoGetFiles
{
  my( $Client ) = @_;
  my @RemoteFileList ;

  ## Skip if the client directory already exists.
  if( -d "$path/$Client" ){ print  "$Client exists.\n"; next; }

  ## PATH to feed to BPDIR:
  my $bppath = "/usr/openv/netbackup";

   #if($OS =~ /windows/)  {
   #    &MakeDirectory($path, $Client);
      # `($BPPath/bin/admincmd/bpgetconfig -M $Client 
1>$path/$Client/bpconfig.txt 2>\&1)`;
       #`grep '^Include =' $path/$Client/bpconfig.txt
>$path/$Client/include_list`;
       #`grep '^Exclude =' $path/$Client/bpconfig.txt
>$path/$Client/exclude_list`;
       #print  "Windows client Information gotten.";
       #return;
  #}  else  {
     ## BPDIR:
     my @FileList = `$bppath/bin/admincmd/bpdir -M $Client $bppath`;

     ## GREP into an array all significant Remote Files found.
     @RemoteFileList =
                grep( /clude_list|bp.conf|last_successful_hostname/,
@FileList);

     ## hardcoded.
     # @RemoteFileList =("include_list",
"exclude_list","include_list.Full-Monthly",
     # "exclude_list.Full-Monthly","include_list.Incremental-Daily",
     # "exclude_list.Incremental-Daily","bp.conf");
  #}

  ## If there are config files to process...CJM
  if ( @RemoteFileList )  {
      ## MAKEDIR the log dir.
      &MakeDirectory($path, $Client);

      ## Cycle thru those files found to get 'em all.CJM
      foreach my $RemoteFile ( @RemoteFileList )      {
        ## strip off extra whitespace (fr and ba)
        $RemoteFile =~ s/^\s+//;
        $RemoteFile =~ s/\s+$//;

        ## get the filename from BPDIR output.
        ## the filename is d
        my( $a, $b, $c, $filename, $e, $f ) = split( /\s+/, $RemoteFile
);
        print  "-Getting remote file: $filename.";

        ## Go get the remote file.CJM
        `($BPPath/bin/bpgp from $Client $bppath/$filename
$path/$Client/$filename)\&`;

      } ## End foreach
  }  else  {
    print  "NO files to get.";
    return;
  } ## EndIf

  return;
}

------------------------------ snip ---------------------------------



>* Clooney, David <david.clooney at bankofamerica.com> [2006-08-15 12:35]:
>  
>
>>Hi all
>> 
>>Trying to rollout an upgrade of  x number of solaris clients , the 
>>problem I have is the SA'a want to simply remove the package and then 
>>add the new, which will detroy any exclude_lists out there in the 
>>environment.
>> 
>>I use bpgp quite a bit in secured environments and find very useful 
>>indeed, albeit I have seen technotes in the past it cause issues I 
>>have yet to have a prob in the last 4 years.
>> 
>>Problem is that you have to know the specific file you are after on 
>>the client, has anyone incorpated wildcards in some sort of way or 
>>fashion to bring down say,
>>exclude* ??
>>    
>>
>
>Ack! bpgp has no way to use wildcards. If you do try to use wildcards, 
>you will likely destroy something.
>
>Always be very very careful when using bpgp.
>
>  
>

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



Notice to recipient:
The information in this internet e-mail and any attachments is confidential and 
may be privileged. It is intended solely for the addressee. If you are not the 
intended addressee please notify the sender immediately by telephone. If you 
are not the intended recipient, any disclosure, copying, distribution or any 
action taken or omitted to be taken in reliance on it, is prohibited and may be 
unlawful.

When addressed to external clients any opinions or advice contained in this 
internet e-mail are subject to the terms and conditions expressed in any 
applicable governing terms of business or client engagement letter issued by 
the pertinent Bank of America group entity.

If this email originates from the U.K. please note that Bank of America, N.A., 
London Branch and Banc of America Securities Limited are authorised and 
regulated by the Financial Services Authority.



<Prev in Thread] Current Thread [Next in Thread>