#!/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 job id\n";
print "3) This option will allow you to eject tapes from the silo\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 expiration\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 = );
if($choosen == 1){
print "What backup job are you looking for? \n";
chomp($pid = );
print "Is it Active or a Done job? (Act or Done): ";
chomp($act = );
if($act eq "Act"){
#system("rm backup.state");
system(" /opt/openv/netbackup/bin/admincmd/bpdbjobs -report -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 -report -format_file /home/schmijg/.xbpmonrc > backup.state");
system(" cat backup.state | grep $pid | grep Done > job.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 = );
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 = );
print "Ejecting tape please wait";
system("vmchange -vh sapbu001 -mt dlt -res -rt none -rc1 0 -rc2 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 silo: ";
chomp($tapeid = );
print "prossesing";
system("vmquery -b -rn 0 | grep $tapeid");
}elsif($choosen == 5){
print "\n\nHow many tapes would you like to eject?(no more then 20) ";
chomp($ejectnu = );
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\}\' > selected.txt ");
system("cat selected.txt");
print "Would you like to eject these tapes? (yes or no)\a ";
chomp($yes = );
if( $yes eq "yes"){
print "We Will be ejecting $ejectnu tapes";
system("cat selected.txt | xargs -lt vmchange -vh sapbu001 -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 eject 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 then 20) ";
chomp($ejectnu = );
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 = );
if( $yes eq "yes"){
print "We Will be ejecting $ejectnu tapes";
system("cat selected.txt | xargs -L1 -t vmchange -vh sapbu001 -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 = );
print "What is the client host that this class will be kicked off on?\n";
chomp($client_host = );
print "Kicking of manual backup of $class on $client_host. \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=);
print "\n Which media server would you like to do the inventory? ";
chomp($medsvr=);
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";
}
perlmonks.org content © perlmonks.org and JSchmitz
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03