Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Netbackup Utility

by JSchmitz (Canon)
on Mar 13, 2006 at 19:19 UTC ( [id://536349]=sourcecode: print w/replies, xml ) Need Help??
Category: utility
Author/Contact Info JefferySchmitz@mac.com
Description: Front end for doing Netbackup tasks simply. They have an asci menu tool called bpadm but it's kind of a pain in the wazoo.
#!/usr/bin/perl -w
#system("clear");

#######                                                               
+  ######
####### Quick script to do simple queries and kills of netbackup jobs 
+  ######
####### Checks for tapes, and Ejects tapes                            
+  ######



print "\n \n \n \nThis script will Do various tasks to make netbackup 
+life easier\n\n\n";
print "1)       This option will query the database for a selected job
+\n";
print "2)       This option will kill an Active job by giving it the j
+ob id\n";
print "3)       This option will allow you to eject tapes from the sil
+o\n";
print "4)       Check Silo for tapes\n";
print "5)       Quick eject of tapes that are full\n";
print "6)       Quick eject of tapes that are full and Infinity expira
+tion\n";
print "7)       Checks the scratch pool... for available media\n";
print "8)       Kickoff a backup by class.\n";
print "9)       Inventory New tapes in the Silo\n\n\n";
print "Choose between 1 - 9: ";
chomp($choosen = <STDIN>);

if($choosen == 1){
        print "What backup job are you looking for? \n";
        chomp($pid = <STDIN>);
        print "Is it Active or a Done job? (Act or Done): ";
        chomp($act = <STDIN>);

        if($act eq "Act"){
                #system("rm backup.state");
                system(" /opt/openv/netbackup/bin/admincmd/bpdbjobs -r
+eport -format_file /home/schmijg/xbpmonrc > backup.state");
                system(" cat backup.state | grep $pid | grep Active > 
+job.txt");
                system(" cat job.txt");
                print "\n if you would like to view it later type in..
+.. cat job.txt \n";
        }elsif($act eq "Done"){
                system(" /opt/openv/netbackup/bin/admincmd/bpdbjobs -r
+eport -format_file /home/schmijg/.xbpmonrc > backup.state");
                system(" cat backup.state | grep $pid | grep Done > jo
+b.txt");
                print "\n type in.... cat job.txt \n";
                system("cat job.txt");
                print "\n if you would like to view it later type in..
+.. cat job.txt \n";
        }else{
                 print "No other options avialiable \n\n";
}


}elsif($choosen == 2){
        print"What is the name of the process needed to be killed?\n";
        chomp($pid = <STDIN>);
        print "Killing pid $pid\n\n";
        system("/opt/openv/netbackup/bin/admincmd/bpdbjobs -kill $pid"
+);
}elsif($choosen == 3){
        print "\n \nWhat tape would you like to eject?   ";
        chomp($tapeid = <STDIN>);
        print "Ejecting tape please wait";
        system("vmchange -vh sapbu001 -mt dlt -res -rt none -rc1 0 -rc
+2 0 -e -sec 5 -m $tapeid");
        print "tape ejected";
}elsif($choosen == 4){
        print "\n \nEnter the tape number to check if it is in the sil
+o:   ";
        chomp($tapeid = <STDIN>);
        print "prossesing";
        system("vmquery -b -rn 0 | grep $tapeid");

}elsif($choosen == 5){
        print "\n\nHow many tapes would you like to eject?(no more the
+n 20)  ";
        chomp($ejectnu = <STDIN>);
        system("/var/tmp/avail.ksh");
        system("cat /var/tmp/full_tapes_in_robot.txt | grep -i full > 
+full.txt");
        system("tail -$ejectnu full.txt \| awk \'\{print \$1\}\' > sel
+ected.txt ");
        system("cat selected.txt");
        print "Would you like to eject these tapes? (yes or no)\a  ";
        chomp($yes = <STDIN>);
                if( $yes eq "yes"){
                print "We Will be ejecting $ejectnu tapes";
                system("cat selected.txt | xargs -lt vmchange -vh sapb
+u001 -mt dlt -res -rt none -rc1 0 -rc2 0 -e -sec 5 -m ");
                print "\n Tapes have been ejected";
                        }elsif($yes eq "no"){
                        exit
                }

}elsif($choosen == 6){
        print "This will print out a list of tapes that you could ejec
+t that are full and expire infinity.\n\n";
        system("/var/tmp/avail.ksh");
        system("cat full_infinity_tapes_robot.txt | awk \'\{print \$1,
+ \$4, \$11, \$13 \}\'");
        print "\n\nHow many tapes would you like to eject?(no more the
+n 20)  ";
        chomp($ejectnu = <STDIN>);
        system("tail -$ejectnu full_infinity_tapes_robot.txt \| awk \'
+\{print \$1\}\' > selected.txt");
        system("cat selected.txt");
        print "Would you like to eject these tapes? (yes or no)\a  ";
        chomp($yes = <STDIN>);
                if( $yes eq "yes"){
                print "We Will be ejecting $ejectnu tapes";
                system("cat selected.txt | xargs -L1 -t vmchange -vh s
+apbu001 -mt dlt -res -rt none -rc1 0 -rc2 0 -e -sec 5 -m ");
                print "\n Tapes have been ejected";
                        }elsif($yes eq "no"){
                        exit
                }

}elsif($choosen == 7){
        system("/home/schmijg/checkscratch.sh");

}elsif($choosen == 8){
        print "This will give you a list of backup classes\n\n";
        system("sleep 2");
        system("/opt/openv/netbackup/bin/admincmd/bpcllist -allclasses
+ \| grep -i class \| awk \'\{print \$1, \$2\}\'\n\n");
        print "which backup class would you like to do a manual backup
+ off?\n";
        chomp($class = <STDIN>);
        print "What is the client host that this class will be kicked 
+off on?\n";
        chomp($client_host = <STDIN>);
                print "Kicking of manual backup of $class on $client_h
+ost. \n";
                system("sleep 2");
                system("/usr/openv/netbackup/bin/bpbackup -c $class -i
+ -h $client_host -L /tmp/$client_host.out");
}elsif($choosen == 9){
        print "This will look for any new tapes added to the silo and 
+put it into netbackup control\n\n";
        print "What is the hostname for the Master Server?   ";
        chomp($mstr=<STDIN>);
        print "\n Which media server would you like to do the inventor
+y?   ";
        chomp($medsvr=<STDIN>);
        print "\nBegining to Inventory Then New Tapes In the Silo";
        system("vmupdate -rn 0 -rt acs -M $mstr -use_barcode_rules -rh
+ $medsvr");
        system("sleep 3");
}else{
        print "No other options avialiable \n \n";
}
Replies are listed 'Best First'.
Re: Netbackup Utility
by Anonymous Monk on May 11, 2011 at 19:18 UTC
    whats in your /home/schmijg/xbpmonrc file?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: sourcecode [id://536349]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-24 22:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found