Anyone have a nice script for tapes that are "Full"

We are looking to make room in our Library, and thought if we ejected the full tapes and put them on-sight it would work best for us.

I can see full tapes in the Media List from the GUI, but I cant figure for the life of me how to get them from the command line.

Appreciate any help you can give.

Thank you.
16 Replies

Re: Anyone have a nice script for tapes that are "Full"

You can find FULL media from the status field of bpmedialist.


# /usr/openv/netbackup/bin/admincmd/bpmedialist -mlist -l
CKG1 *NULL* 1 13 1110740965 1111004095 1113682495 0 3991872 18 18 3 6 0 0 1024 0 124784 0 0 0 0 0 0 0
CKG2 *NULL* 1 13 1111086566 1111090471 1113768871 0 958400 4 4 3 7 0 0 1024 0 29960 0 0 0 0 0 0 0
DIFF1 *NULL* 1 13 1110864594 1111007347 1111612147 0 32030272 4 3 0 10 0 40 1024 0 233 0 0 0 0 0 0 0
FULL3 *NULL* 1 13 1110864925 1110864925 1111469725 0 357760 1 1 0 5 0 0 1024 0 11184 0 0 0 0 0 0 0

15th field represents medium status. If "(15th field) & 0x08" is true, medium is FULL. Status field of DIFF1 is 40(0x28), so FULL bit is true.

Another way is to use "/usr/openv/netbackup/bin/goodies/available_media" script - I found FULL bit from this script. But it takes a lot of time to run with thousands of media.

Re: Anyone have a nice script for tapes that are "Full"

Here is available_plus for unix. To be put in /usr/openv/netbackup/bin/goodies/

#! /bin/ksh
# $Header: available_plus.sh,v 1.4.2.2 2005/02/01 $
# Original available_media.sh 1.4.2.1 modified
# - ORPHANfor assigned volumes not present in mediaDB
# - NONEfor volumes in volume pool None not subject to selection
# - DBBACKUPstatus definitely reserved for catalog backup volumes, thanks to vmstatus=1
# - EXPIRATION DATE instead of PARTNER SIDE (only used with optical device) This is is MEDIA Expiration Date, based on Retention Level of the longest living image in the base
# - CAN BE LAUNCHED from any UNIX console or media server
#
#***************************************************************************
#* $VRTScprght: Copyright 1993 - 2004 VERITAS Software Corporation, All Rights Reserved $
#***************************************************************************
#
# available_plus
#
# This script can be used by an administrator as a convenient way to
# list ALL NetBackup volumes in the Media Manager volume database, and
# augment that list with information on the volumes currently "assigned"
# to NetBackup.
# The major benefit of this script is that it eliminates the need to track
# information from multiple databases and do the correlation manually.
#
# This script can be used in a crontab entry to get periodic reports of
# available media.
#
#

# =============================================================================
get_med_type()
{
typelen=${#vmediatype}
if
then
vmediatype="$vmediatype "
elif
then
vmediatype="$vmediatype "
elif
then
vmediatype="$vmediatype "
elif
then
vmediatype="$vmediatype "
elif
then
vmediatype="$vmediatype "
fi
}
# =============================================================================

if
then
echo "usage: $0 "
exit 0
fi

VMQUERY=/usr/openv/volmgr/bin/vmquery
VMPOOL=/usr/openv/volmgr/bin/vmpool
BPMEDIALIST=/usr/openv/netbackup/bin/admincmd/bpmedialist

if
then
HARDWARE=`head -1 /usr/openv/netbackup/version | cut -f2 -d" "`
else
echo "/usr/openv/netbackup/version not found"
exit 1
fi

TR=/usr/bin/tr

case "$HARDWARE" in
SUN4)
TR=/bin/tr
;;
RS6000)
TR=/bin/tr
;;
SOLARIS)
TR=/bin/tr
;;
esac

/bin/rm -rf /tmp/avail_media_output
/bin/rm -rf /tmp/avail_media_sorted_output
/bin/touch /tmp/avail_media_output

TAB=`/bin/echo ' ' | $TR ' ' '\011'`

VMPOOL_OUTPUT=/tmp/vmpool_output
/bin/rm -rf $VMPOOL_OUTPUT
touch $VMPOOL_OUTPUT

$VMPOOL -listall -b 2>/dev/null | tail +3 | sort +0 1>$VMPOOL_OUTPUT 2>/dev/null

BPMEDIALIST_OUTPUT=/tmp/bpmedialist_output
/bin/rm -rf $BPMEDIALIST_OUTPUT
touch $BPMEDIALIST_OUTPUT

#$BPMEDIALIST -mlist -l 1>$BPMEDIALIST_OUTPUT 2>/dev/null
#$BPMEDIALIST -U |tail +6 |
#$BPMEDIALIST -U |/usr/xpg4/bin/grep -ve ^$ -e Server -e images -e "----" |
$BPMEDIALIST -U |grep -v ^$ |grep -v Server|grep -v images|grep -v |
awk '
BEGIN {flag = 0}
NR%2==1 {flag = 1;info = $1 " " $2 " " $(NF-1);
next}
flag==1 {expd=substr($0,21,10); if (substr($0,57,4)!="") status=substr($0,57,19);
else status="ACTIVE";
print info " " expd " " status;
flag = 0;
next}'>$BPMEDIALIST_OUTPUT 2>/dev/null

VMQUERY_OUTPUT=/tmp/vmquery.out
ASTERISK_DISPLAYED=/tmp/asterisk_displayed

cat $VMPOOL_OUTPUT |
while read poolname poolhost pooluser poolgroup pooldesc
do
/bin/rm -rf $VMQUERY_OUTPUT
/bin/rm -rf /tmp/avail_media_output
touch $VMQUERY_OUTPUT
$VMQUERY -pn $poolname -W 2>/dev/null | tail +3 1>>$VMQUERY_OUTPUT 2>/dev/null

cat $VMQUERY_OUTPUT |
while read vmediaid vop vmediatype vbar vbarpar vrobh vrobottype vrobotnum vrobotslot vside vvol vpool vpooln vprevpo vmnts vmax vclean vcrdate vcrtime vasgndate vasgntime vfmtdate vfmttime vlmtdate vlmttime vexpdate vexptime vstatus vremainder
do
/bin/rm -rf /tmp/bpmediaid_found

if
then
if
then
bpstatus=NONE
bpkbytes="0"
bpretlev="-"
else
bpstatus=AVAILABLE
bpkbytes="0"
bpretlev="-"
fi

get_med_type

/bin/echo "$vmediaid${TAB}$vmediatype $vrobottype${TAB} $vrobotnum${TAB} $vrobotslot${TAB} "-"${TAB}${TAB} $bpretlev $bpkbytes${TAB}$bpstatus" >>/tmp/avail_media_output

else
grep "^$vmediaid" $BPMEDIALIST_OUTPUT |
#while read bpmediaid bppartner bpver bpden bpalloc bplwrite bpexp bplrest bpkbytes bpnimages bpvimages bpretlev bpunused1 bpnumrest bpstat bprest
while read bpmediaid bpretlev bpkbytes bpexpd bpstatus
do
/bin/touch /tmp/bpmediaid_found

get_med_type
bpkbytes=`expr $bpkbytes / 1024`

/bin/echo "$vmediaid${TAB}$vmediatype $vrobottype${TAB} $vrobotnum${TAB} $vrobotslot${TAB} $bpexpd${TAB} $bpretlev $bpkbytes${TAB}$bpstatus" >>/tmp/avail_media_output

done

if
then
if
then
bpkbytes="?"
bpretlev="?"
bpstatus=ORPHAN
else
bpkbytes="N/A"
bpretlev="-"
bpstatus=DBBACKUP
fi
get_med_type

/bin/echo "$vmediaid${TAB}$vmediatype $vrobottype${TAB} $vrobotnum${TAB} $vrobotslot${TAB} "-"${TAB}${TAB} $bpretlev${TAB}$bpkbytes${TAB}$bpstatus" >>/tmp/avail_media_output

fi
fi
done

/bin/echo "$poolname pool" >>/tmp/avail_media_sorted_output
/bin/echo "" >>/tmp/avail_media_sorted_output

# Sort the entries on media id.

if
then
cat /tmp/avail_media_output | sort +8 +0 >> /tmp/avail_media_sorted_output
/bin/echo "" >>/tmp/avail_media_sorted_output
fi
done


/bin/echo "media${TAB}media${TAB}robot${TAB}robot${TAB}robot${TAB}expiration${TAB}ret size${TAB}status"
/bin/echo " ID${TAB}type${TAB}type${TAB} #${TAB}slot${TAB}date${TAB}${TAB}level MBytes"
/bin/echo "----------------------------------------------------------------------------"

/bin/cat /tmp/avail_media_sorted_output

if
then
echo
echo "* - More than 1 retention level present."
echo
/bin/rm -rf ${ASTERISK_DISPLAYED}
fi

if
then
echo "Summary:"
echo ""
echo "#Media Pool Type State"
echo "------ ---------- ---------- -----"
awk '{
if ( $2 == "pool" ) pool = substr($1" ",1,10)
if ( NF == 9 ) s++
}
END {
for (state in s)
printf("%6d %s\n",s,state)
}' /tmp/avail_media_sorted_output | sort +1
fi

/bin/rm -rf /tmp/avail_media_sorted_output /tmp/avail_media_output $VMQUERY_OUTPUT $VMPOOL_OUTPUT $BPMEDIALIST_OUTPUT

Re: Anyone have a nice script for tapes that are "Full"

Here is available_plus for windows.

It MUST be copied in ...NetBackup\bin\goodies\

@REM
@REM $Header: available_plus.cmd,v 1.3 2005/02/01 $
@REM Original available_media.cmd 1.2 modified
@REM - ORPHAN for assigned volumes not present in mediaDB
@REM - NONE for volumes in volume pool None not subject to selection
@REM - DBBACKUP status definitely reserved for catalog backup volumes, thanks to vmstatus=1
@REM - EXPIRATION DATE instead of PARTNER SIDE (only used with optical device) This is is MEDIA Expiration Date, based on Retention Level of the longest living image in the base
@REM bcpyrght
@REM ***************************************************************************
@REM * $VRTScprght: Copyright 1993 - 2003 VERITAS Software Corporation, All Rights Reserved $ *
@REM ***************************************************************************
@REM ecpyrght
@REM
@REM available_plus.cmd
@REM
@REM This script can be used by an administrator as a convenient way to
@REM list ALL NetBackup volumes in the Volume Manager database, and
@REM augment that list with information on the volumes currently "assigned"
@REM to NetBackup.
@REM The major benefit of this script is that it eliminates the need to track
@REM information from multiple databases and do the correlation manually.
@REM
@REM This script can be used to get periodic reports of available media by
@REM registering it with the AT command.
@REM
@REM
@REM - Main program ------------------------------------------------------------

@REM -

@REM - This script only runs on NT 4.0 and succeeding versions of NT. You must

@REM - have command extensions enabled. Check the following registry entry:

@REM -

@REM - HKEY_CURRENT_USER\Software\Microsoft\Command Processor\EnableExtensions

@REM -

@REM - It should be set to 0x1 or you may have problems running this script.

@REM ---------------------------------------------------------------------------

@setlocal ENABLEEXTENSIONS

@goto StartMain

@REM - Subroutines -------------------------------------------------------------

:FormatOutput

@REM -

@REM - FormatOutput formats the output of the available_media script.

@REM ---------------------------------------------------------------------------

@REM - bpstatus=%1

@REM - vmediaid=%2

@set vmediatype=%3

@if "%vmediatype%" == "" set vmediatype=%vmediatype%

@if "%vmediatype:~1,1%" == "" set vmediatype=%vmediatype%

@if "%vmediatype:~2,1%" == "" set vmediatype=%vmediatype%

@if "%vmediatype:~3,1%" == "" set vmediatype=%vmediatype%

@if "%vmediatype:~4,1%" == "" set vmediatype=%vmediatype%

@if "%vmediatype:~5,1%" == "" set vmediatype=%vmediatype%

@if "%vmediatype:~6,1%" == "" set vmediatype=%vmediatype%

@if "%vmediatype:~7,1%" == "" set vmediatype=%vmediatype%

@REM - vrobottype=%4

@REM - vrobotnum=%5

@REM - vrobotslot=%6

@REM - vside=%7

@set bpretlev=%8

@if "%bpretlev:~1,1%" == "" set bpretlev=%bpretlev%

@REM - bpkbytes=%9

@echo %2%vmediatype% %4 %5 %6%7%bpretlev%%9%1

@goto :EOF

@REM ---------------------------------------------------------------------------

Smiley TonguerocessAssignedMedia

@REM -

@REM - ProcessAssignedMedia gets the status, KBytes used and retention level of

@REM - the media.

@REM ---------------------------------------------------------------------------

@set bpstatus=

@REM set bpmediaid=%1

@shift /1

@REM set bppartner=%1

@shift /1

@REM set bpver=%1

@shift /1

@REM set bpden=%1

@shift /1

@REM set bpalloc=%1

@shift /1

@REM set bplwrite=%1

@shift /1

@REM set bpexp=%1
@set bpexp=%1


@shift /1

@REM set bplrest=%1

@shift /1

@set bpkbytes=%1

@shift /1

@REM set bpnimages=%1

@shift /1

@REM set bpvimages=%1

@shift /1

@set bpretlev=%1

@shift /1

@REM set bpunused1=%1

@shift /1

@REM set bpnumrest=%1

@shift /1

@set bpstat=%1

@REM shift /1

@REM set bprest=%1

@set ismpx=0

@REM ---------------------------------------------------------------------------

@REM - Translate bpstat into a string

@REM ---------------------------------------------------------------------------

@if NOT %bpstat% GTR 511 goto Test255

@set ismpx=1

@set /A bpstat-=512

@REM ---------------------------------------------------------------------------

:Test255

@if NOT %bpstat% GTR 255 goto Test127

@REM - Ignore this bit.

@set /A bpstat-=256

@REM ---------------------------------------------------------------------------

:Test127

@if NOT %bpstat% GTR 127 goto Test63

@set /A bpstat-=128

@set bpstatus=IMPORTED

@REM ---------------------------------------------------------------------------

:Test63

@if NOT %bpstat% GTR 63 goto Test31

@set /A bpstat-=64

@REM - Add * on retention level to indicate this media id has multiple

@REM - retention levels on it.

@set bpretlev=%bpretlev%*

@set /A ASTERISK_DISPLAYED+=1

@REM ---------------------------------------------------------------------------

:Test31

@if NOT %bpstat% GTR 31 goto Test15

@REM - Ignore this bit.

@set /A bpstat-=32

@REM ---------------------------------------------------------------------------

:Test15

@if NOT %bpstat% GTR 15 goto Test7

@REM - Ignore this bit.

@set /A bpstat-=16

@REM ---------------------------------------------------------------------------

:Test7

@if NOT %bpstat% GTR 7 goto Test3

@set /A bpstat-=8

@if NOT "%bpstatus%" == "" set bpstatus=%bpstatus%/

@set bpstatus=%bpstatus%FULL

@REM ---------------------------------------------------------------------------

:Test3

@if NOT %bpstat% GTR 3 goto Test1

@REM - Ignore this bit.

@set /A bpstat-=4

@REM ---------------------------------------------------------------------------

:Test1

@if NOT %bpstat% GTR 1 goto Test0

@set /A bpstat-=2

@if NOT "%bpstatus%" == "" set bpstatus=%bpstatus%/

@set bpstatus=%bpstatus%SUSPENDED

@REM ---------------------------------------------------------------------------

:Test0

@if NOT %bpstat% GTR 0 goto NotFrozen

@if NOT "%bpstatus%" == set bpstatus=%bpstatus%/

@set bpstatus=%bpstatus%FROZEN

@REM ---------------------------------------------------------------------------

:NotFrozen

@if NOT %ismpx% GTR 0 goto NoMpx

@if NOT "%bpstatus%" == "" set bpstatus=%bpstatus%/

@set bpstatus=%bpstatus%MPX

@goto :EOF

@REM ---------------------------------------------------------------------------

:NoMpx

@if "%bpstatus%" == "" set bpstatus=ACTIVE

@goto :EOF

@REM ---------------------------------------------------------------------------

Smiley TonguerocessVolume

@REM -

@REM - ProcessVolume prints a line of output for the current volume (prior

@REM - to sorting).

@REM ---------------------------------------------------------------------------

@set vmediaid=%1

@shift /1

@set vop=%1

@shift /1

@set vmediatype=%1

@shift /1

@set vbarcode=%1

@shift /1

@set vbarpartner=%1

@shift /1

@set vrobhost=%1

@shift /1

@set vrobottype=%1

@shift /1

@set vrobotnum=%1

@shift /1

@set vrobotslot=%1

@shift /1

@set vside=%1

@shift /1

@set vvol=%1

@shift /1

@set vpool=%1

@shift /1

@set vpoolnum=%1

@shift /1

@set vprevpool=%1

@shift /1

@set vmnts=%1

@shift /1

@set vmaxmnts=%1

@shift /1

@set vclns=%1

@shift /1

@set vcrdate=%1

@shift /1

@set vcrtime=%1

@shift /1

@set vasgndate=%1

@shift /1

@set vasgntime=%1

@shift /1

@set vfmtdate=%1

@shift /1

@set vfmttime=%1

@shift /1

@set vlmtdate=%1

@shift /1

@set vlmttime=%1

@shift /1

@set vexpdate=%1

@shift /1

@set vexptime=%1

@shift /1

@set vstatus=%1

@shift /1

@set bpkbytes=?

@set bpretlev=?

@REM ---------------------------------------------------------------------------

@REM - Check if this volume has been assigned.

@REM ---------------------------------------------------------------------------

@if NOT "%vasgndate%" == "00/00/0000" goto TestCat

@if NOT "%vasgntime%" == "00:00" goto TestCat

@REM ---------------------------------------------------------------------------

@REM - The volume is not assigned.

@REM ---------------------------------------------------------------------------

@if "%vpool%" == "None" goto NonePool

@set bpstatus=AVAILABLE

@set bpkbytes=-

@set bpretlev=-

@goto EndProcessVolume

@REM ---------------------------------------------------------------------------

:NonePool

@set bpstatus=NONE

@set bpkbytes=N/A

@set bpretlev=N/A

@goto EndProcessVolume

@REM ---------------------------------------------------------------------------

@REM - The volume is assigned.

@REM ---------------------------------------------------------------------------

:TestCat

@if NOT "%vstatus%" == "1" goto MediaAssigned

@set bpkbytes=N/A

@set bpretlev=N/A

@set bpstatus=DBBACKUP

@goto EndProcessVolume

:MediaAssigned

@set bpstatus=ORPHAN

@for /F "delims=" %%i in ('%BPMEDIALIST% -mlist -l -ev %vmediaid%') do @call Smiley TonguerocessAssignedMedia %%i

:EndProcessVolume

@REM ---------------------------------------------------------------------------

@REM - Print the volume information.

@REM ---------------------------------------------------------------------------

@for /F "tokens=1,2,3,4,5,6,7* delims= " %%i in ('%BPDBM% -ctime %bpexp%') do @set bpexpd=%%m%%l%%o

@set bpexpe=%bpexpd:~0,5%%bpexpd:~7,2%

@if "%bpexp%"=="0" set bpexpe=N/A

@set /A bpkbytesd=%bpkbytes%/1024

@echo %bpstatus% %vmediaid% %vmediatype% %vrobottype% %vrobotnum% %vrobotslot% %bpexpe% %bpretlev% %bpkbytesd%

@goto :EOF

---------------------------------------------------------------------------

Smiley FrustratedtripVmQueryOut

@REM -

@REM - StripVmQueryOut strips the headers from the output of vmquery.

@REM ---------------------------------------------------------------------------

@for /F "skip=2 delims=" %%i in ('%VMQUERY% -pn %1 -W') do @call Smiley TonguerocessVolume %%i

@goto :EOF

@REM ---------------------------------------------------------------------------

:ListVolumes

@REM -

@REM - ListVolumes creates a list of volumes in the current pool.

@REM ---------------------------------------------------------------------------

@call Smiley FrustratedtripVmQueryOut %1 > %OUTPUT_FILE% 2> nul

@REM - Sort the records by status

@sort < %OUTPUT_FILE% > %VOLUMES%

@echo %1 pool

@%LISTPATHS% /s BlankLine

@for /F "delims=" %%i in ('type %VOLUMES%') do @call :FormatOutput %%i

@%LISTPATHS% /s BlankLine

@goto :EOF

@REM ---------------------------------------------------------------------------

:ListVolumePools

@REM -

@REM - ListVolumePools creates a list of the volume pools.

@REM ---------------------------------------------------------------------------

@for /F "skip=2" %%i in ('%VMPOOL% -listall -b') do @echo %%i

@goto :EOF

@REM - continue Main program ---------------------------------------------------

Smiley FrustratedtartMain

@REM ---------------------------------------------------------------------------

@REM - Make sure the user is not running another instance of available_media

@REM - because of the use of temporary output files.

@REM ---------------------------------------------------------------------------

@set LISTPATHS="%~dp0\listpaths"

@set LOCKFILE="%TEMP%\AM.%USERNAME%.lok"

@if NOT exist %LOCKFILE% goto SetLock

@echo You are already running Available_Media. 1>&2

@echo Try again later. 1>&2

@goto EndMain

Smiley FrustratedetLock

@echo %USERNAME% > %LOCKFILE%

@REM ---------------------------------------------------------------------------

@REM - Locate the Media Manager binaries.

@REM ---------------------------------------------------------------------------

@for /F "delims=|" %%p in ('%LISTPATHS% /s VM_BIN_VMQUERY') do @set VMQUERY="%%p"

@for /F "delims=|" %%p in ('%LISTPATHS% /s VM_BIN_VMPOOL') do @set VMPOOL="%%p"

@for /F "delims=|" %%p in ('%LISTPATHS% /s BPMEDIALIST') do @set BPMEDIALIST="%%p"

@for /F "delims=|" %%p in ('%LISTPATHS% /s BP_BIN') do @set BPDBM="%%p\bpdbm"

@REM ---------------------------------------------------------------------------

@REM - Create the output file names.

@REM ---------------------------------------------------------------------------

@set OUTPUT_FILE="%TEMP%\AM.%USERNAME%.out"

@set POOLS="%TEMP%\AM.%USERNAME%.pools"

@set VOLUMES="%TEMP%\AM.%USERNAME%.volumes"

@REM ---------------------------------------------------------------------------

@REM - Create an alphabetized volume pool list (AM..pools).

@REM ---------------------------------------------------------------------------

@call :ListVolumePools > %OUTPUT_FILE% 2> nul

@sort < %OUTPUT_FILE% > %POOLS%

@REM ---------------------------------------------------------------------------

@REM - Print the column labels.

@REM ---------------------------------------------------------------------------

@echo mediamediarobotrobotrobotexpret sizestatus

@echo IDtypetype #slotdatelevel MBytes

@echo ----------------------------------------------------------------------------

@REM ---------------------------------------------------------------------------

@REM - For each volume pool, list the volumes.

@REM ---------------------------------------------------------------------------

@set ASTERISK_DISPLAYED=0

@for /F %%i in ('type %POOLS%') do @call :ListVolumes %%i

@if %ASTERISK_DISPLAYED% EQU 0 goto CleanUp

@REM ---------------------------------------------------------------------------

@REM - Add multiple retention level footnote.

@REM ---------------------------------------------------------------------------

@%LISTPATHS% /s BlankLine

@echo * - More than 1 retention level present.

@%LISTPATHS% /s BlankLine

@REM ---------------------------------------------------------------------------

:CleanUp

@if exist %VOLUMES% del %VOLUMES%

@del %OUTPUT_FILE%

@del %POOLS%

@del %LOCKFILE%

:EndMain

@endlocal

@REM - End of Main Program -----------------------------------------------------

Re: Anyone have a nice script for tapes that are "Full"

AHA, my favourite subject. I can't compete with the epic scripts above, but what i've been doing for 5yrs is run the same basic script i've always used ; Basically i like simple, so i just run available_media script, go thru the output looking for 'TLD' and 'FULL', and send a mail. Oh and don't forget a 3yr old technote - http://seer.support.veritas.com/docs/199300.htm (problem is still with us in 4.5)

The output too is v simple -

A list of FULL UNIX NetBackup tapes to be removed from Tape Robot today -

Tue Mar 22 08:30:18 GMT 2005



Eject tapes via
'vmchange -res -multi_eject -w -verbose -rn 0 -rt tld -rh nthsunbackup -vh nthsunbackup -ml x:y:z'

Also, don't forget to resync the Robot Inventory via
'vmupdate -rt tld -rn 0 -rh nthsunbackup -vh nthsunbackup -use_barcode_rules -empty_map'
after any tapes are removed from/re-introduced to Tape Robot.


MediaID Type Robot Type/No Slot/Retention KBytes
------- ---- ------------- -------------- ------
5727L1HCART TLD 0 46 - 0 310604021FULL/MPX
5739L1HCART TLD 0 51 - 0 319146953FULL/MPX
5743L1HCART TLD 0 37 - 1 169626655FULL/MPX
5758L1HCART TLD 0 29 - 0 310498919FULL/MPX
5761L1HCART TLD 0 41 - 3 307622885FULL/MPX
5795L1HCART TLD 0 21 - 0 311455829FULL/MPX
5841L1HCART TLD 0 8 - 0 310073193FULL/MPX
5896L1HCART TLD 0 20 - 3 303275250FULL/MPX
5935L1HCART TLD 0 30 - 3 303361956FULL/MPX

Total FULL Unix tapes to remove today = 9

Re: Anyone have a nice script for tapes that are "Full"

I always just run
/usr/openv/netbackup/bin/goodies/available_media | grep FULL

Re: Anyone have a nice script for tapes that are "Full"

Try this one for %age full statistics

#! /bin/ksh
# $Header: average_full.sh 1.0 2005/03/20 $
# Must be in /usr/openv/netbackup/bin/goodies/
# This script gives you average filling of media by volume pool and %age filling of actual assigned media.
#
# Will create and use one file for each volume pool in /usr/openv/netbackup/bin/goodies/stats_files
# Each volume pool file is used as statistics reference for all the FULL media ever added to it and generate after calculation the average size of its medias.
# This assumes NetBackup uses one pool for each Application / OS / nature of files, which directly modifies the compression rate
# =============================================================================

if
then
echo "usage: $0 "
exit 0
fi

if
then
FILTER=ALL
else
FILTER=FAST
fi

if
then
HARDWARE=`head -1 /usr/openv/netbackup/version | cut -f2 -d" "`
else
echo "/usr/openv/netbackup/version not found"
exit 1
fi

TR=/usr/bin/tr

case "$HARDWARE" in
SUN4)
TR=/bin/tr
;;
RS6000)
TR=/bin/tr
;;
SOLARIS)
TR=/bin/tr
;;
esac

VMPOOL=/usr/openv/volmgr/bin/vmpool
VMPOOL_OUTPUT=/tmp/vmpool_output
BPMEDIALIST=/usr/openv/netbackup/bin/admincmd/bpmedialist
BPMEDIALIST_OUTPUT=/tmp/bpmedialist_output
BPMEDIAFULL_OUTPUT=/tmp/bpmediafull_output
OUTPUTDIR=/usr/openv/netbackup/bin/goodies/stats_files
TAB=`/bin/echo ' ' | $TR ' ' '\011'`

if
then
touch /tmp/.nothing
else
mkdir $OUTPUTDIR 2>/dev/null
fi

/bin/rm -rf $BPMEDIALIST_OUTPUT
/bin/rm -rf $BPMEDIAFULL_OUTPUT
/bin/rm -rf $OUTPUTDIR/pool_stats
/bin/rm -rf $VMPOOL_OUTPUT
touch $BPMEDIALIST_OUTPUT
touch $BPMEDIAFULL_OUTPUT
touch $VMPOOL_OUTPUT

$VMPOOL -listall -b 2>/dev/null | tail +3 | sort +0 1>$VMPOOL_OUTPUT 2>/dev/null

if
then
echo "--------------------------------------------------------"
echo "Calculation af average filling rate for each Volume Pool"
echo "--------------------------------------------------------"

cat $VMPOOL_OUTPUT |
while read poolname poolhost pooluser poolgroup pooldesc
do
$BPMEDIALIST -U -p $poolname |grep -v ^$ |grep -v Server|grep -v images|grep -v |
awk '
BEGIN {flag = 0}
NR%2==1 {flag = 1;med = $1 ; size=$(NF-1);
next}
flag==1 {expd=substr($0,21,16); if (substr($0,57,4)!="") status=substr($0,57,19);
else status="ACTIVE";
print med " " size/1024 " Mb " expd " " status;
flag = 0;
next}' >> $OUTPUTDIR/$poolname 2>/dev/null
cat $OUTPUTDIR/$poolname |tail +2|sort|uniq >$OUTPUTDIR/$poolname

AVERAGE=`nawk '/FULL/ {number++; total += $2} END {if (number!=0) print total/number; else print 0}' $OUTPUTDIR/$poolname` 2>/dev/null
NUMBER=`grep FULL $OUTPUTDIR/$poolname |wc -l`

echo "Average size of" $NUMBER" full media in" $poolname " ${TAB}" $AVERAGE " Mb" > $OUTPUTDIR/tmp 2>/dev/null

grep FULL $OUTPUTDIR/$poolname >> $OUTPUTDIR/tmp 2>/dev/null
mv $OUTPUTDIR/tmp $OUTPUTDIR/$poolname
head -1 $OUTPUTDIR/$poolname >> $OUTPUTDIR/pool_stats 2>/dev/null
done

cat $OUTPUTDIR/pool_stats
fi
echo
echo "------------------------------------"
echo "Statistics for actual assigned media"
echo "------------------------------------"

cat $VMPOOL_OUTPUT |
while read poolname poolhost pooluser poolgroup pooldesc
do
AVERAGE=`head -1 $OUTPUTDIR/$poolname |nawk '{print $9}'`
echo $poolname
$BPMEDIALIST -l -p $poolname > $OUTPUTDIR/.tmp
cat $OUTPUTDIR/.tmp |
while read bpmediaid bppartner bpver bpden bpalloc bplwrite bpexp bplrest bpkbytes bpnimages bpvimages bpretlev bpunused1 bpnumrest bpstat bprest
do
/bin/touch /tmp/bpmediaid_found

bpstatus=""
spaces=" "
ismpx=0

# Translate bpstat into a string

if
then
ismpx=1
bpstat=`expr $bpstat - 512`
fi

if
then
# Ignore this bit.
bpstat=`expr $bpstat - 256`
fi

if
then
bpstat=`expr $bpstat - 128`
bpstatus=IMPORTED
fi

if
then
bpstat=`expr $bpstat - 64`
# Add * on retention level to indicate
# this media id has multiple retention
# levels on it. Reduce the number of
# spaces to account for the *.
bpretlev=${bpretlev}*
spaces=" "
touch $ASTERISK_DISPLAYED
fi

if
then
# Ignore this bit.
bpstat=`expr $bpstat - 32`
fi

if
then
# Ignore this bit.
bpstat=`expr $bpstat - 16`
fi

if
then
bpstat=`expr $bpstat - 8`
if
then
bpstatus=FULL
else
bpstatus=${bpstatus}/FULL
fi
fi

if
then
# Ignore this bit.
bpstat=`expr $bpstat - 4`
fi

if
then
bpstat=`expr $bpstat - 2`
if
then
bpstatus=SUSPENDED
else
bpstatus=${bpstatus}/SUSPENDED
fi
fi

if
then
if
then
bpstatus=FROZEN
else
bpstatus=${bpstatus}/FROZEN
fi
fi

if
then
if
then
bpstatus=ACTIVE/MPX
else
bpstatus=ACTIVE
fi
else
if
then
bpstatus=${bpstatus}/MPX
fi
fi
if
then
echo "$bpmediaid `expr $bpkbytes / 1024`Mb${TAB}$bpstatus${TAB} at `expr 100 \* $bpkbytes / $AVERAGE / 1024`%"
else
echo "$bpmediaid `expr $bpkbytes / 1024`Mb${TAB}$bpstatus${TAB} at `expr 100 \* $bpkbytes / $AVERAGE / 1024`% Expire at `/usr/openv/netbackup/bin/bpdbm -ctime $bpexp`"
fi
done
echo
done

/bin/rm -rf $VMPOOL_OUTPUT $BPMEDIALIST_OUTPUT $BPMEDIAFULL_OUTPUT

Re: Anyone have a nice script for tapes that are "Full"

Output sample of the previous script :
--------------------------------------------------------
Calculation af average filling rate for each Volume Pool
--------------------------------------------------------
Average size of 0 full media in DataStore 0 Mb
Average size of 1 full media in frnt1 104897 Mb
Average size of 0 full media in NetBackup 0 Mb
Average size of 0 full media in None 0 Mb

------------------------------------
Statistics for actual assigned media
------------------------------------
DataStore

frnt1
A00000 0Mb FROZEN at 0%
A00001 78710Mb FROZEN at 75% Expire at 1109267663 = Thu Feb 24 17:54:23 2005
A00002 104896Mb FULL at 99% Expire at 1109267663 = Thu Feb 24 17:54:23 2005
A00003 0Mb FROZEN at 0%
A00004 0Mb FROZEN at 0%
A00005 0Mb FROZEN at 0%
A00006 0Mb FROZEN at 0%
A00007 0Mb SUSPENDED at 0%

Re: Anyone have a nice script for tapes that are "Full"

> DIFF1 *NULL* 1 13 1110864594 1111007347 1111612147 0
> 32030272 4 3 0 10 0 40 1024 0 233 0 0 0 0 0 0 0
> FULL3 *NULL* 1 13 1110864925 1110864925 1111469725 0
> 357760 1 1 0 5 0 0 1024 0 11184 0 0 0 0 0 0 0
>
> 15th field represents medium status. If "(15th
> h field) & 0x08" is true, medium is FULL. Status
> field of DIFF1 is 40(0x28), so FULL bit is true.
>

Ho do you test this if "(15th field ) & 0x08 " ?
Are you in shell ? in Perl ? in Batch ?

Can you give me the complete test command ?

I've been dreaming of this analysis !

Re: Anyone have a nice script for tapes that are "Full"

Thanks for all the feedback, I was able to create a script that would generate a list of TLD media that is full and email it to the correct people to remove them from the Library. Now here is an operational problem I ran into.

We only want to eject full media that is older then a week, this is for what we call our business critical backups, that may require a quick restore. We feel keeping a weeks worth of full tapes in the library wont hurt us by much. So my new question to this comunity is:

How can I sort the output from available_media to find media that has not been mounted in 7 days ?

I dont see any media mount information on available_media output, I do on bpmedialist output, but thats a totally different script that is formatted kind of bad (two lines of output under the header for each mediaID).

If anyone has any idea's, I would appreciate the feedback.

Thank you.


Maurice
Xerox

Re: Anyone have a nice script for tapes that are "Full"

I get this error:
D:\VERITAS\NetBackup\bin\goodies>available_plus
media media robot robot robot exp ret size status
ID type type # slot date level MBytes
----------------------------------------------------------------------------
DataStore pool


NetBackup pool

The syntax of the command is incorrect.
D:\VERITAS\NetBackup\bin\goodies>@if "~1,1bpretlev
D:\VERITAS\NetBackup\bin\goodies>

Any ideas? NetBackup 5.1 MP2 on Windows Server 2003.
Command extensions are enabled (by default).

Re: Anyone have a nice script for tapes that are "Full"

bpmedialist -l

This gives you the 4 dates : Assignation, Expiration, Last Write, Last read. You'll find in the manual which is the last write.
use bpdbm -ctime <10_digit_Date> to convert it to a readble format.
You can adapt yourself the available_media or available_plus if you want it to specify the Last Write date instead of the Expiration date.

Cheers

Don't forget to award points to those who helped you.

Re: Anyone have a nice script for tapes that are "Full"

Strange you server don't accept this syntax. In order to backup the command file I do not use a classic text editor. I use word, and force it to backuo the file under a windows format with double quotes for the name.
Try the syntax of ~1,1 under a dos window, this is a filter for minus 1 character syntax.

Re: Anyone have a nice script for tapes that are "Full"

We'd been pushing the limits of our Scalar 1000 full of 8mm tapes to the limit as our data center kept growing and growing. We had to rotate in scratch tapes almost every day. I wrote this script to eject the 18 full tapes inside with the latest image expiration dates. I set it for 18 because that's how many 8mm's a Scalar 1000's MAP holds.

You'll notice it is tailored to ignore tapes in a couple of pools, RMAN_test and Oracle, that we frequently restored from. In later revisions I added stuff in the "sort out medialist" section to ignore tapes recently written to. Customize it to your own environment iif you like it.

#!/usr/bin/perl
#######################
### some constants
#######################
$BPMEDIALIST = "/opt/openv/netbackup/bin/admincmd/bpmedialist -rt tld -l";
$TEMPFILE = "/tmp/mediareporttmp.out";
$VMQUERY = "/opt/openv/volmgr/bin/vmquery -w -a";
$TIME = time();
%STATUSCODES = (0,'ACTIVE',1,'FROZEN',2,'SUSPENDED',3,'FROZEN/SUSP',8,'FULL');

###########################
### get bpmedialist output
###########################
system "$BPMEDIALIST > $TEMPFILE";
open ( TEMPFILE , $TEMPFILE ) || die "**ERROR1 OPENING FILE $TEMPFILE**\n";
while () { push(@medialist, $_);}
close( TEMPFILE );
system "rm $TEMPFILE";

###########################
### get vmquery output
###########################
system "$VMQUERY > $TEMPFILE";
open ( TEMPFILE , $TEMPFILE ) || die "**ERROR2 OPENING FILE $TEMPFILE**\n";
while () { push(@vmquery, $_);}
close( TEMPFILE );
system "rm $TEMPFILE";

###########################
### sort out medialist
###########################
# 0. media id
# 1. partner id
# 2. version
# 3. density
# 4. time allocated
# 5. time last written
# 6. time of expiration
# 7. time last read
# 8. Kbytes
# 9. nimages
# 10. vimages (unexpired images)
# 11. retention level
# 12. volume pool
# 13. number of restores
# 14. status in hex, >=0x008 (1000) Full. >=0x004 (0100) unreported. >=0x002 (0010) Suspended. ==0x001 (0001) Frozen. ==0x000 (0000) Active.
# 15. hsize
# 16. ssize
# 17. l_offset
# 18. reserved
# 19. psize
# 20. reserved
# 21. 4 reserved fields
foreach(@medialist){
@temp = split;
$STATUS{$temp} = (($temp | 4080) ^ 4080);
if ( $STATUS{$temp} == 8){push(@FULLTAPEStemp, $temp . ' ' . $temp);}
else {}
}

@FULLTAPEStemp = reverse sort @FULLTAPEStemp;
@FULLTAPES=0;
foreach(@FULLTAPEStemp){ push(@FULLTAPES, (split)); }
###########################
### sort out vmquery
###########################
# 0. media ID
# 1. optical partner
# 2. media type
# 3. barcode
# 4. barcode partner
# 5. robot host
# 6. robot type
# 7. robot #
# 8. robot slot
# 9. side/face
# 10. volume group
# 11. pool
# 11. pool #
# 12. prev pool
# 12. # of mounts
# 13. max mounts
# 14. # of cleanings
# 15. create date
# 16. create time
# 17. assigned date
# 18. assigned time
# 19. first mount date
# 20. first mount time
# 21. last mount date
# 22. last mount time
# 23. expiration date
# 24. expiration time
# 25. status
# 26. offsite location
# 27. off sent date
# 28. off sent time
# 29. off return date
# 30. off return time
# 31. off slot
# 32. of ses id
# 33. version
# 34. description
shift(@vmquery); shift(@vmquery); shift(@vmquery);
$SCRATCH = 0;
foreach(@vmquery){
@temp = split;
$ROBOT{$temp} = $temp;
$ROBOT{$temp} = $temp;
if ( $ROBOT{$temp} eq TLD && $ROBOT{$temp} ne RMAN_test && $ROBOT{$temp} ne Oracle){push(@ROBOTAPES, $temp);}
else {}
}

###########################
### compare bpmedialist and vmquery
###########################
# assume @A and @B are already loaded
%seen = (); # lookup table to test membership of B
@both = (); # answer

# build lookup table
foreach $item (@ROBOTAPES) { $seen{$item} = 1 }

# find only elements in both @FULLTAPES and @ROBOTAPES
foreach $item (@FULLTAPES) {
if ($seen{$item}) {
# it's not in %seen, so add to @both
push(@both, $item);
}
}
###########################
### Output
###########################
$syntax = sprintf "$both\:$both\:$both\:$both\:$both\:$both\:$both\:$both\:$both\:$both\:$both\:$both\:$both\:$both\:$both\:$both\:$both\:$both\n";

system "/usr/openv/volmgr/bin/vmchange -res -multi_eject -w -verbose -rn 0 -rt tld -rh wbpbkup01 -ml $syntax" ;
system "vmupdate -rn 0 -rt tld -rh wbpbkup01"
##### ##### #####
# # # #
#### # # ####
# # # #
##### ##### #

Re: Anyone have a nice script for tapes that are "Full"

checked above and i hadn't posted my simple script to go with my previous reply -

My Nice and simple 5yr old solution for using standard available_media script to generate FULL tapes list (this is run via cron every day) -

#!/bin/ksh
#
# - first check if NetBackup is running or not.
#
if ; then echo "This email was generated by script that produces FULL tapes report - '/home/richardb/full_tapes.sh'" | /usr/ucb/mail -s "NetBackup doesn't appear to be running - pls investigate ASAP - nthsunbackup @`date +%d/%m-%H:%M`" emailaddy@somewhere

else

# - if NetBackup is running, ONLY THEN produce report.
#
/usr/openv/netbackup/bin/goodies/available_media > /home/richardb/script-output/all_tapesz.txt

echo > /home/richardb/script-output/full_tapes.txt
echo "A list of FULL UNIX NetBackup tapes to be removed from Tape Robot today - " >> /home/richardb/script-output/full_tapes.txt
echo >> /home/richardb/script-output/full_tapes.txt
date >> /home/richardb/script-output/full_tapes.txt
echo >> /home/richardb/script-output/full_tapes.txt

echo "" >> /home/richardb/script-output/full_tapes.txt
echo >> /home/richardb/script-output/full_tapes.txt

echo "Eject tapes via" >> /home/richardb/script-output/full_tapes.txt

echo "'vmchange -res -multi_eject -w -verbose -rn 0 -rt tld -rh `hostname` -vh `hostname` -ml x:y:z'" >> /home/richardb/script-output/full_tapes.txt
echo >> /home/richardb/script-output/full_tapes.txt

echo "Also, don't forget to resync the Robot Inventory via " >> /home/richardb/script-output/full_tapes.txt
echo "'vmupdate -rt tld -rn 0 -rh `hostname` -vh `hostname` -use_barcode_rules -empty_map'" >> /home/richardb/script-output/full_tapes.txt
echo "after any tapes are removed from/re-introduced to Tape Robot." >> /home/richardb/script-output/full_tapes.txt
echo >> /home/richardb/script-output/full_tapes.txt
echo >> /home/richardb/script-output/full_tapes.txt

cat /home/richardb/script-output/titlebar2.txt >> /home/richardb/script-output/full_tapes.txt

cat /home/richardb/script-output/all_tapesz.txt | grep "TLD"|grep "FULL"|sort >> /home/richardb/script-output/full_tapes.txt
echo >> /home/richardb/script-output/full_tapes.txt

cat /home/richardb/script-output/all_tapesz.txt | grep "TLD"|grep "FULL" | wc | awk '{sum+=$1} END {printf " Total FULL Unix tapes to remove today = %d\n",sum}' >> /home/richardb/script-output/full_tapes.txt
echo >> /home/richardb/script-output/full_tapes.txt

cat /home/richardb/script-output/full_tapes.txt | /usr/ucb/mail -s "Netbackup - List of FULL tapes - nthsunbackup @`date +%d/%m-%H:%M`" emailaddy@somewhere

fi



sample output from script -


A list of FULL UNIX NetBackup tapes to be removed from Tape Robot today -

Tue Jun 28 08:30:20 BST 2005



Eject tapes via
'vmchange -res -multi_eject -w -verbose -rn 0 -rt tld -rh nthsunbackup -vh nthsunbackup -ml x:y:z'

Also, don't forget to resync the Robot Inventory via 'vmupdate -rt tld -rn 0 -rh nthsunbackup -vh nthsunbackup -use_barcode_rules -empty_map'
after any tapes are removed from/re-introduced to Tape Robot.


MediaID Type Robot Type/No Slot/Retention KBytes
------- ---- ------------- -------------- ------
5753L1HCART TLD 0 51 - 0 287637586FULL/MPX
5840L1HCART TLD 0 50 - 0 328209751FULL/MPX
5916L1HCART TLD 0 22 - 1 226374572FULL/MPX
5919L1HCART TLD 0 53 - 0 290153524FULL/MPX
5922L1HCART TLD 0 32 - 0 341916702FULL/MPX
5934L1HCART TLD 0 11 - 0 314948025FULL/MPX
5939L1HCART TLD 0 4 - 0 307094552FULL/MPX
5941L1HCART TLD 0 18 - 2 207328768FULL

Total FULL Unix tapes to remove today = 8



Rich

Re: Anyone have a nice script for tapes that are "Full"

did this prove useful at all ?

Re: Anyone have a nice script for tapes that are "Full"

Actually the posts must be folowed up. So that in future they can be referred to.

With some Juicy points also :-)