Rebuilding a Netbackup environment with a fresh start

Written by:

While performing some disaster recovery testing, I wanted to be able to rebuild our netbackup 7.5 environment before going thru the restore process. My goal was to remove all media from the NBU EMM database, remove all tape drives and robot configuration then rebuild. Came up with the following script to do that and it worked just as expected.

#!/bin/ksh

delete_drives() {
/usr/openv/volmgr/bin/vmglob -listall | perl -ne 'print if /device type:\s*robot/../robot number:/ ' | while read line
do
   if [ "`echo $line | grep '^serial number:'" ]; then
      serialnum=`echo $line | awk '{print $3}'`
   fi

   if [ "`echo $line | grep '^hostname:'" ]; then
      vhostname=`echo $line | awk '{print $2}'`
   fi

   if [ "`echo $line | grep '^robot number:'" ]; then
      robotnum=`echo $line | awk '{print $3}'`
      /usr/openv/volmgr/bin/vmglob -delete -robot -serial $serialnum -robnum $robotnum -devhost $vhostname
   fi

   # echo $line
done

}

delete_robots() {
/usr/openv/volmgr/bin/vmglob -listall | perl -ne 'print if /device type:\s*drive/../drive type:/ ' | while read line
do
   if [ "`echo $line | grep '^serial number:'" ]; then
      serialnum=`echo $line | awk '{print $3}'`
   fi

   if [ "`echo $line | grep '^hostname:'" ]; then
      vhostname=`echo $line | awk '{print $2}'`
   fi

   if [ "`echo $line | grep '^device name:'" ]; then
      drivename=`echo $line | awk '{print $3}'`
   fi

   if [ "`echo $line | grep '^drive type:'" ]; then
      drvtype=`echo $line | awk '{print $3}'`
      /usr/openv/volmgr/bin/vmglob -delete -drive -drvtype $drvtype -serial $serialnum -name $drivename -devhost $vhostname
   fi

done

}

# Delete all tape drives
# tpconfig -l | grep hcart | awk '{print $3}'|sort -u | nawk '{system("tpconfig -delete -drive "$1)}'
delete_drives

# Delete all robots
# tpconfig -l | grep robot | awk '{print $2}'|sort -u | nawk '{system("tpconfig -delete -robot "$1)}'
delete_robots

# Run autoconfig
/usr/openv/volmgr/bin/tpautoconf -a -v

# restart ltid
/usr/openv/volmgr/bin/stopltid
sleep 4
/usr/openv/volmgr/bin/ltid

robot=`/usr/openv/volmgr/bin/tpconfig -l|grep robot|awk '{print $2}'`

# Cleanup media id's
#  hummm, dont remember why we need this
/usr/openv/volmgr/bin/vmquery -h `hostname` -a | grep "media ID:"|grep T | nawk '{system("/usr/openv/volmgr/bin/vmdelete -m "$3)}'

# Inventory robot
/usr/openv/volmgr/bin/vmupdate  -rn $robot -rt TLD -rh `hostname`

This code bit was run on a Solaris 10 Sparc system but I bet it could be run on any other Unix system.

Rebuilding a Netbackup environment with a fresh start
0 votes, 0.00 avg. rating (0% score)

Leave a Reply