Showing results for 
Search instead for 
Did you mean: 

Script to Mail Details of Full Medias with Only Yearly Retention

Level 3

Hi Folks,


Anyone please help me to get a script which trigger Mail with Details of Full Medias with Only Yearly Retention date. We don't want to eject those medias as I checked few scripts in this forum which eject those which are full. In our environment we will do the ejection manually but we want mail with details mentioning which medias are full and its expiration date is after one year only.Moreover, We created one vault profile but its ejecting only one media and waiting for MAP to be cleared before ejecting next one. If anyone help me in this where all media will be ejected at once. I am not sure about access port as it may allow to eject only one media which I still have to confirm from onsite support.

Master server : Windows 2008 R2

Netbackup  Version : 7.1

Library :One T50e spectra logic – 2 LTO5 Drives


Thanks in Advance,

Nitesh Kumar



Level 6
Partner Accredited Certified

Hi Niteshry,

Try to review below link. It might help you in creating script using BLAT and nbmail.cmd


Level 3

Thanks Adonis for the Link but, actually I need script which will trigger a mail mentioning full tapes with 1 year retention details only.

Not applicable

Scripting's not my strong point but you could wrap the following around the nbmail.cmd as that will get your output to your email.

First you would need to find out the retention level defined in your Netbackup environment.

Via commands this would be


Or in the GUI under Master Server properties > Retention Periods

use that value (the default value for 1 year retention level = 8)

The following command will mention the tapes (1st column)

bpmedialist -l -rl 8

The output from this is will give you all tapes in the 1 year retention level (column 1) then you need to filter this output by the 15th column and those with a value 8 which defines status FULL media

Media status is all discussed here: bpmedialist


Or rely on the available_media.cmd script on your server to be sent. Or similarly email the Media Summary report output of 'bpmedialist -summary [-U|-L]'

Level 6
Partner Accredited Certified

Pop this in a file named oneyear.bat somewhere on your master server and have windows scheduler run it when you want it to (edit the install path if you need to) and relace 8 after the -rl with the level you use for a 1 year retention - assume blat is installed and configured on yoru Master Server:

"c:\program files\veritas\netbackup\bin\admincmd\bpmedialist" -rl 8 -U >c:\1year.txt
blat c:\1year.txt -s "1 year retnetion tapes" -t


Hope this helps - merry Xmas


noticed you wanted "Full" media - have to work a bit more on that one!!

Level 6
Partner Accredited Certified

AH! What the heck - its Christmas - try this....

On the master make a directory c:\tapes\

In there make two files named oneyear.bat and oneyear.vbs

Right click and edit oneyear.bat and paste in (editing the path and -rl number to suit):

"c:\program files\veritas\netbackup\bin\admincmd\bpmedialist" -rl 8 -l >c:\tapes\1year.txt
blat c:\tapes\fulltapes.txt -s "1 year retnetion tapes" -t

Save than and then right click and edit the oneyear.vbs and paste in the following - nothing to edit in this one:

Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\tapes\1year.txt", ForReading)

Do Until objFile.AtEndOfStream
    strLine = objFile.ReadLine
    arrFields = Split(strLine, " ")

    If InStr(arrFields(14), "8") Then
        strContents = strContents & arrFields(0) & vbCrlf
    End If


strContentsa = "Media ID" & vbCrlf

Set objFile = objFSO.CreateTextFile("C:\tapes\fulltapes.txt")
objFile.Write strContentsa

objFile.Write strContents



Have windows scheduler run the oneyear.bat file for you - nice neat result

Hope this helps

Level 3

Thanks a lot Mark/Stuart..I still have to try these Script. You know it's Holiday Time. cheeky

Level 6
Partner Accredited Certified

Holiday - what is one of those - LOL!

Have a good break and New Year - to give you an idea my last script pipes out something like this:

Media ID

Thought that was nice and simple and the sort of thing you were looking for.

Level 6
Partner Accredited Certified

Did you ever try these?