Any automated NetBackup Inventory script?

sprasad
Posts: 24
Joined: Sun Oct 09, 2016 2:52 pm

Any automated NetBackup Inventory script?

Postby sprasad » Sun Oct 09, 2016 2:58 pm

Any automated NetBackup Inventory script?

San
Posts: 24
Joined: Sun Oct 09, 2016 2:53 pm

Re: Any automated NetBackup Inventory script?

Postby San » Sun Oct 09, 2016 3:00 pm

In NetBackup environment inventory needs to be done on regular basis.
Here is the script for doing the same. Script has been prepared in shell language and will run in kourne shell. With this script we can run inventory either for the whole library or for a particular robot depending upon the need.
This script can be used in any scheduler which automatically runs depending on the requirement like 2 times in a day or once a day
Two things to check before using this and run as an appropriate owner
1) Is vmupdate is being used as a nonroot_admin command (Any user with proper privilages can run this command)
2) Is vmupdate is being used as a root admin command (This command can be run only as root)

Key Feature:
1) Input needs to be given while running the script.
2) If in case no input is given then, it will question whether we need to inventory a particular robot or all the robots.
3) It will give an error and exit out of the script if the robot which needs to be inventory is in AVR mode.
4) It will give an error if we enter a non existing robot number for inventory.

5) This can be run in any UNIX environment without any modification.



Source code:

Here is the source code for the script:



#!/usr/bin/ksh
echo "*********************************************************"
echo "script is running for `hostname` environment"
echo "*********************************************************"
if [ "$1" = "all" ] ; then

#finding robots defined in the current environment

/usr/openv/volmgr/bin/tpconfig -emm_dev_list -noverbose | grep ROBOT | awk {'print$5'} | sort -u > /tmp/robot
for i in `cat /tmp/robot`
do
rh=`/usr/openv/volmgr/bin/tpconfig -emm_dev_list -noverbose | grep ROBOT$i | awk -F" " {'if($14=="-") print$6'} | awk -F"." {'print$1'}`


#finding corresponding robottype

rtraw=`/usr/openv/volmgr/bin/tpconfig -emm_dev_list -noverbose | grep ROBOT$i | awk -F" " '{if($14=="-") print$4}'`
case "$rtraw" in
0) rt=NONE ;;
1) rt=ACS ;;
2) rt=TS8 ;;
5) rt=ODL ;;
6) rt=TL8 ;;
7) rt=TL4 ;;
8) rt=TLD ;;
10) rt=TSD ;;
11) rt=TSH ;;
12) rt=TLH ;;
13) rt=TLM ;;
17) rt=LMF ;;
18) rt=RSM ;; esac
if [ "$rt" = "NONE" ] ; then
echo "Need to check the robot $1"
else
echo "Robot $i is in working order so, initiating the inventory command"
echo "Inventory is running for robot $i type $rt robotic host $rh"
/usr/openv/volmgr/bin/vmupdate -rt $rt -rn $i -rh $rh -interactive -use_barcode_rules -empty_map
fi
done
elif [ "$1" = "" ] ; then
echo "do you to inventory all robots ?(y/n)"
read ans
if [ "$ans" = "y" ]; then
#robot contains all the robots of the current environment
/usr/openv/volmgr/bin/tpconfig -emm_dev_list -noverbose | grep ROBOT | awk {'print$5'} | sort -u > /tmp/robot
for i in `cat /tmp/robot`
do
rh=`/usr/openv/volmgr/bin/tpconfig -emm_dev_list -noverbose | grep ROBOT$i | awk -F" " {'if($14=="-") print$6'} | awk -F"." {'print$1'}`
#finding corresponding robottype
rtraw=`/usr/openv/volmgr/bin/tpconfig -emm_dev_list -noverbose | grep ROBOT$i | awk -F" " '{if($14=="-") print$4}'`
case "$rtraw" in
0) rt=NONE ;;
1) rt=ACS ;;
2) rt=TS8 ;;
5) rt=ODL ;;
6) rt=TL8 ;;
7) rt=TL4 ;;
8) rt=TLD ;;
10) rt=TSD ;;
11) rt=TSH ;;
12) rt=TLH ;;
13) rt=TLM ;;
17) rt=LMF ;;
18) rt=RSM ;; esac
if [ "$rt" = "NONE" ] ; then
echo "Need to check the robot $1"
else
echo "Robot $i is in working order so, initiating the inventory cmd"
echo "Inventory is running for robot $i type $rt robotic host $rh"
/usr/openv/volmgr/bin/vmupdate -rt $rt -rn $i -rh $rh -interactive -use_barcode_rules -empty_map
fi
done
else
/usr/openv/volmgr/bin/tpconfig -emm_dev_list -noverbose | grep ROBOT | awk {'print$5'} | sort -u > /tmp/robot
echo "available robots in `hostname` environment are \n`cat /tmp/robot`"
echo "enter a robot number for which inventory needs to be done"
read i
a=`grep $i < /tmp/robot |wc -l`
if [ $a -eq 1 ] ; then
rh=`/usr/openv/volmgr/bin/tpconfig -emm_dev_list -noverbose | grep ROBOT$i | awk -F" " {'if($14=="-") print$6'} | awk -F"." {'print$1'}`

rtraw=`/usr/openv/volmgr/bin/tpconfig -emm_dev_list -noverbose | grep ROBOT$i | awk -F" " {'if($14=="-")print$4}`
case "$rtraw" in
0) rt=NONE ;;
1) rt=ACS ;;
2) rt=TS8 ;;
2) rt=TS8 ;;
5) rt=ODL ;;
6) rt=TL8 ;;
7) rt=TL4 ;;
8) rt=TLD ;;
10) rt=TSD ;;
11) rt=TSH ;;
12) rt=TLH ;;
13) rt=TLM ;;
17) rt=LMF ;;
18) rt=RSM ;; esac
if [ "$rt" = "NONE" ] ; then
echo "Need to check the robot $i"
else
echo "Robot$i is in working order so, initiating the inventory command"
echo "Inventory is running for robot $i type $rt with robotic host $rh"
/usr/openv/volmgr/bin/vmupdate -rt $rt -rn $i -rh $rh -interactive -use_barcode_rules -empty_map
fi
else
echo "Robot number : $i is not valid"
fi
else
/usr/openv/volmgr/bin/tpconfig -emm_dev_list -noverbose | grep ROBOT | awk {'print$5'} | sort -u > /tmp/robot
echo "available robots in `hostname` environment are \n`cat /tmp/robot`"
/usr/openv/volmgr/bin/tpconfig -emm_dev_list -noverbose | grep ROBOT | awk {'print$5'} | sort -u > /tmp/robot
a=`grep $1 < /tmp/robot |wc -l`
if [ $a -eq 1 ] ; then
rh=`/usr/openv/volmgr/bin/tpconfig -emm_dev_list -noverbose | grep ROBOT$1 | awk -F" " {'if($14=="-") print$6'} | awk -F"." {'print$1'}`
rtraw=`/usr/openv/volmgr/bin/tpconfig -emm_dev_list -noverbose | grep ROBOT$1 | awk -F" " {'if($14=="-")print$4}`
case "$rtraw" in
0) rt=NONE ;;
1) rt=ACS ;;
2) rt=TS8 ;;
2) rt=TS8 ;;
5) rt=ODL ;;
6) rt=TL8 ;;
7) rt=TL4 ;;
8) rt=TLD ;;
10) rt=TSD ;;
11) rt=TSH ;;
12) rt=TLH ;;
13) rt=TLM ;;
17) rt=LMF ;;
18) rt=RSM ;; esac
if [ "$rt" = "NONE" ] ; then
echo "Need to check the robot $i"
else
echo "Robot$1 is in working order and initiating the inventory command"
echo "Inventory is running for robot $1 type $rt with robotic host $rh"
/usr/openv/volmgr/bin/vmupdate -rt $rt -rn $i -rh $rh -interactive -use_barcode_rules -empty_map
fi
else
echo "Robot number : $1 is not valid"
fi
#removing the file robot
sesudo rm /tmp/robot
fi




Pre requites to use the script : User should have Unix Admin and Net backup level 1 Knowledge to run the script.



How to use:

Input needs to be given while running the script:

#sh <filename> <all/robot number>

Suppose file name is inventory

1. Inventory for all robots:
#sh inventory all

2. Inventory for single robot eg. For robot 2:
#sh inventory 2

3. If in case no input is given then the script will interact and question whether inventory needs to be done for all or for a particular robot.

do you to inventory all robots ?(y/n)


If it needs to be done for all the robots then y needs to be selected else n. If y is selected then inventory will be done for all the robots. Else again we need to give the robot number.


1) If we enter a invalid robot number then it will prompt as below and exit out of the script

Robot is not valid.

2) if robot is in AVR mode then it will prompt as below and exit out of the script

Need to check the robot.


Return to “Scripting”

Who is online

Users browsing this forum: No registered users and 1 guest