Perl netbackup script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl netbackup script?
# 8  
Old 01-06-2010
Ok, no problem. The script works and it gives me the output that I wan't to see thanks for the help!
# 9  
Old 01-06-2010
Sure, here's the updated script with the changes suggested in the earlier post, in red color. I hope you were able to figure them out yourself.

Code:
$
$ cat netbkup.pl
#!/usr/bin/perl -w
system("/usr/openv/netbackup/bin/admincmd/bpimagelist -L -hoursago 24 > /tmp/Tapelog.txt");
open (CSVFILE, ">MK_Tapes_To_Be_Pulled.csv") or die "Can't open MK_Tapes_To_Be_Pulled.csv for output: $!";
open (LINKLIST, "</tmp/Tapelog.txt") or die "Can't open /tmp/Tapelog.txt: $!";
print CSVFILE "Client,Policy,Schedule Type,Backup Time, Elapsed Time, Kilobytes,Media Date\n";
while (<LINKLIST>) {
  chomp;
  next if /^\s*$/; # skip this line if it is blank or has nothing but whitespace
  s/^\s+//;
  s/\s+$//;
  ($key, $value) = ($_=~ m!(.*?):(.+)!);
  $value =~ s/^\s+//;
  $value =~ s/\s+$//;
  printf("%-40s %-s\n",$key,$value);
  $client = $value if /^Client:/;
  $policy = $value if /^Policy:/;
  $schedule = $value if /^Schedule Type/;
  $backuptime = $value if /^Backup Time/;
  $elapsedtime = $value if /^Elapsed Time/;
  $mediatape = $value if /^Media Date: /;
  $kilobytes = $value if /^Kilobytes/;
  print CSVFILE  "$client,$policy,$schedule,$backuptime,$elapsedtime,$kilobytes,$mediatape\n" if /resume/ ;
}
close (CSVFILE)  or die "Can't close output file Tapes_To_Be_Pulled.csv: $!";
close (LINKLIST) or die "Can't close file /tmp/Tapelog.txt: $!";
$
$

The alternative is to remove the "-w" warnings switch on first line. But I wouldn't recommend that.

tyler_durden
# 10  
Old 01-27-2010
Late post but better late then never right.
For the system part in red i could have guessed it.
I add some code to the script also.

Code:
cat nbureport.pl
#!/usr/bin/perl -w
$bdate=$ARGV[0];
$edate=$ARGV[1];
system("/usr/openv/netbackup/bin/admincmd/bpimagelist -d $bdate -e $edate -L > /tmp/Tapelog.txt");
open (CSVFILE, ">MK_Tapes_To_Be_Pulled.csv") or die "Can't open MK_Tapes_To_Be_Pulled.csv for output: $!";
open (LINKLIST, "</tmp/Tapelog.txt") or die "Can't open /tmp/Tapelog.txt: $!";
print CSVFILE "Client,Policy,Schedule Type,Backup Time, Elapsed Time, Kilobytes\n";
while (<LINKLIST>) {
  chomp;
  next if /^\s*$/; # skip this line if it is blank or has nothing but whitespace
  s/^\s+//;
  s/\s+$//;
  s/ second\(s\)//;
  ($key, $value) = ($_=~ m!(.*?):(.+)!);
  $value =~ s/^\s+//;
  $value =~ s/\s+$//;
  printf("%-40s %-s\n",$key,$value);
  $client = $value if /^Client:/;
  $policy = $value if /^Policy:/;
  $schedule = $value if /^Schedule Type/;
  $backuptime = $value if /^Backup Time/;
  $backuptime = substr($backuptime,0,10);
  $elapsedtime = $value if /^Elapsed Time/;
  $kilobytes = $value if /^Kilobytes/;
  print CSVFILE  "$client,$policy,$schedule,$backuptime,$elapsedtime,$kilobytes\n" if /resume/ ;
}
close (CSVFILE)  or die "Can't close output file Tapes_To_Be_Pulled.csv: $!";
close (LINKLIST) or die "Can't close file /tmp/Tapelog.txt: $!";

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

PERL: In a perl-scripttTrying to execute another perl-script that SETS SOME VARIABLES !

I have reviewed many examples on-line about running another process (either PERL or shell command or a program), but do not find any usefull for my needs way. (Reviewed and not useful the system(), 'back ticks', exec() and open()) I would like to run another PERL-script from first one, not... (1 Reply)
Discussion started by: alex_5161
1 Replies

2. Shell Programming and Scripting

Netbackup Perl Script

please let me know if you can help me out. I need to modify a perl netbackup script to do the following. Will need to enhance a script to do the following: to initiate an incremental during the week and a full only during the weekend. to check if there is another full currently running... (0 Replies)
Discussion started by: Lia123
0 Replies

3. UNIX for Dummies Questions & Answers

Netbackup Report

Would I be able to get the report (text format) of an activity monitor view of a netbackup via command line? I am trying to make a script out of it that would be run daily an be saved in a txt document which would could be viewed for history purpose. I need minimal details only like policy name,... (0 Replies)
Discussion started by: ryan_estiya
0 Replies

4. Solaris

veritas netbackup

Hi All, We are currently running Veritas netbackup. We are currently having a few issues where were unable to log in due to several errors. Out usual fix for this is to recycle the backup servers however due to the nature of the information being backed up this is done by someone else and... (1 Reply)
Discussion started by: rickyclayton201
1 Replies

5. UNIX for Dummies Questions & Answers

Netbackup 6 Question

What is the command to find out if a policy has been run and if it has the date it was last run? (0 Replies)
Discussion started by: mr_crosby
0 Replies

6. Filesystems, Disks and Memory

Netbackup Questions

I have 2 questions maybe those netbackup experts and gurus in the house can help. Firstly, is there a particular location maybe under /usr/openv where I can find a diretory or file which contains all the backup policy information, so lets say If someone were to physically delete all the... (3 Replies)
Discussion started by: sparcguy
3 Replies

7. HP-UX

Netbackup Installation

Hello all. I have a HP-UX 11.11 system that I need to install Netbackup 6.5 onto. After I mount the cd drive and run the 'install' command, it comes back with the following error: usage: install file WHAT options is it talking about? When I look at the documentation from Netbackup, it... (4 Replies)
Discussion started by: impunchdrunk
4 Replies

8. Solaris

Netbackup on Solaris 8

Hi, Anyone know netbackup 3.4 on Solaris 8 . Currently I use root to perform backup / monitoring ...etc . Can I create a user call "backup" and perform the same task What permission should I give the "backup" user . (1 Reply)
Discussion started by: civic2005
1 Replies

9. Filesystems, Disks and Memory

Netbackup question

Hello, I am setting up scripts to do shadow image backups but have found a pitfall I cannot figure out how to work around. Basically what I need to figure out is how to launch a bunch of bpbackups, and then have the script pause until all of the children have exited. The problem is that bpbackup... (2 Replies)
Discussion started by: 98_1LE
2 Replies

10. UNIX for Dummies Questions & Answers

Veritas NetBackup

Veritas NetBackup, how does it work?? I mean, I know it is used for backups and restores but really, can anybody give me a brief or any explanation that sums up basically what it is about besides the fact that it does backups and restores??? Please, if you have any information, I would appreciate... (2 Replies)
Discussion started by: TRUEST
2 Replies
Login or Register to Ask a Question