cancel
Showing results for 
Search instead for 
Did you mean: 

VB Script to pull tape barcodes

jtunn
Level 3

We have a 9 week cycle of backup tapes that are sent daily to an offsite vendor.  Each tape needs to be returned to us on the correct day of the next backup cycle.  I need to notify the vendor as to when the offisite tapes should be returned.  I have been manually filling out forms for them and would like to automate this.

I am writing a VB script to pull the last used tape barcodes, configure the correct date for the tapes to be returned and write this data to a text file.
Does anyone have anything similar written in VB script?  I would like to know how to find the tape barcodes that had been used in the last 24 hours?
I am using NetBackup Ent 6.5.3 for Windows. 

Thank you,

JT

7 REPLIES 7

sdo
Moderator
Moderator
Partner    VIP    Certified
Doesn't Vault do all this for you, and integrate near seemlessly with Iron Mountain?  No forms to fill in.  Iron Mountain automatically know which tape is in which box/container, and which box/container to return when.

jtunn
Level 3
Unfortunately, we are not running Vault :(

sdo
Moderator
Moderator
Partner    VIP    Certified

In ksh:
$sudo bpimmedia -l -tape -d 09/24/2009 17:00:00 -e 09/25/2009 17:00:00 | grep "^FRAG " | awk '{print $9}' | sort -u

In VBS, lots of code, to open files etc...

In DOS:
(excuse the formatting - how do we paste code in this forum?)

@echo off
setlocal enabledelayedexpansion

set z_path=%~dp0
set z_name=%~n0

set z_log=!z_path!!z_name!.log

set z_frg=!z_path!!z_name!.frg
set z_lis=!z_path!!z_name!.lis
set z_med=!z_path!!z_name!.med
set z_out=!z_path!!z_name!.out
set z_srt=!z_path!!z_name!.srt
set z_tmp=!z_path!!z_name!.tmp

if exist "!z_frg!" del "!z_frg!"
if exist "!z_lis!" del "!z_lis!"
if exist "!z_med!" del "!z_med!"
if exist "!z_out!" del "!z_out!"
if exist "!z_srt!" del "!z_srt!"
if exist "!z_tmp!" del "!z_tmp!"

bpimmedia -l -tape -d 09/24/2009 17:00:00 -e 09/25/2009 17:00:00 > "!z_lis!"

find "FRAG " "!z_lis!" > "!z_frg!"

for /f "tokens=1,2,3,4,5,6,7,8,9 skip=2" %%a in ('type "!z_frg!"') do (
  echo %%i >> "!z_med!"
)

sort "!z_med!" /o "!z_srt!"

set z_prv=
for /f "tokens=1" %%a in ('type "!z_srt!"') do (
  set z_cur=%%a
  if not "!z_prv!"=="!z_cur!" (
    if not "!z_prv!"=="" (
      echo !z_cur! >> "!z_out!"
    )
  )
  set z_prv=!z_cur!
)
if not "!z_prv!"=="!z_cur!" (
  if not "!z_prv!"=="" (
    echo !z_cur! >> "!z_out!"
  )
)


:end
echo+
pause
exit /b

 


:log
echo !date! !time:~0,8!  %~1
echo !date! !time:~0,8!  %~1 >> "!z_log!"
goto :eof

sdo
Moderator
Moderator
Partner    VIP    Certified
You'll need additional code to determine the start and end of your backup "session", and to re-format into the MM/DD/YYYY HH:MM:SS format required by the switches -s -e on the bpimmedia command - possibly to accept a parameter (e.g. yesterday, or a session "date" - so that you can re-run perticular dates) etc...

sdo
Moderator
Moderator
Partner    VIP    Certified
Need VBS code to determine start and end of backup session?

jtunn
Level 3
Thank you for the examples!  I will work on it.

sdo
Moderator
Moderator
Partner    VIP    Certified
Ooops... the DOS unique sort should be:

set z_cur=
for /f "tokens=1" %%a in ('type "!z_srt!"') do (
  set z_prv=!z_cur!
  set z_cur=%%a
  if not "!z_prv!"=="!z_cur!" (
    if not "!z_prv!"=="" (
      echo !z_cur! >> "!z_out!"
    )
  )
)
if not "!z_prv!"=="!z_cur!" (
  if not "!z_prv!"=="" (
    echo !z_cur! >> "!z_out!"
  )
)


...the previous post will miss the last occurence when the last occurence is unique.