cancel
Showing results for 
Search instead for 
Did you mean: 

what is the command to find the tapes in library which will expire tomorrow?

NIKHIL234656595
Level 6

what is the command to find the tapes in library which will expire tomorrow?

1 ACCEPTED SOLUTION

Accepted Solutions

mph999
Level 6
Employee Accredited

Yes, that is probably better .. give it a go, if it works then great.

The script could probably be a bit better, it was just a quick way to demonstrate that to do things in netbackup, sometimes you have to use multiple commands, as in this case.

 

Martin

View solution in original post

20 REPLIES 20

Mick_Scott
Level 4
Partner Accredited Certified

Tape Summary Report from Admin Console

or

bpmedialist -summary -U

NIKHIL234656595
Level 6

it gives me all the media list.

I want only those tapes that will expire tmrw?

mph999
Level 6
Employee Accredited

It cannot be done in a single NetBackup command.

The bpmedialist command gives the information, you then have to sort it manually.

For example, I used the very command given by Mick, and then used the operating system (Unix) grep command to filter the results :

 

 

bpmedialist -summary -U |grep expires |grep 02/25/2012
 
R0TP00 expires 02/25/2012 09:15
 
I find that one tape is due to expire tomorrow.
 
Martin

NIKHIL234656595
Level 6

thanks

Chronos
Level 4

#!/bin/bash
bpmedialist -summary | \
   awk \
   ' \
      $2=="expires" && $1~/^W[LR][0-9]*/ \
         {print $1,$2,substr($3,7,4) substr($3,1,2) substr($3,4,2)} \
   ' | \
   sort -k 3.1 | \
   head
 

NIKHIL234656595
Level 6

ho to execute this script?

 

can u tell the complete steps?

Chronos
Level 4

...just like you'd do with any script. In Unix, you just copy the content of the script I gave you in a new file and make it executable:

 

bash# touch script.sh

bash# vi script.sh (paste the script and save it using either Shift+ZZ or :wq )

bash# chmod 770 script.sh (change permissions on the new script)

bash# ./script.sh

mph999
Level 6
Employee Accredited

The script  will only work on unix / linux, not windows.

NIKHIL234656595
Level 6

hi chronos,

At what path to execute this script?

Will_Restore
Level 6

typically  /usr/openv/netbackup/bin/admincmd/  and  /usr/openv/netbackup/bin/

NIKHIL234656595
Level 6

@Martin :i wana know which tapes are in library which will expire tomorrow ?

 

tapes in library not offsited.

 

The command which u told gives list of tapes offsited.

@chronos:when i am running the script ,i am getting the error,

permission denied:bpmedialist not found.

mph999
Level 6
Employee Accredited

You need to be in the directory where the command is located.

/usr/openv/netbackup/bin/admincmd/bpmedialist

Or, (better) - add the paths:

 

/usr/openv/netbackup/bin

/usr/openv/netbackup/bin/admincmd

/usr/openv/volmgr/bin

to the Unix PATH environment variable so that you can run the NetBackup commnads without having to 'cd' to the directories all the time.

Martin

NIKHIL234656595
Level 6

 

bpmedialist -summary -U |grep expires |grep 02/25/2012
 
R0TP00 expires 02/25/2012 09:15
 
 
This command is not working.

Marianne
Level 6
Partner    VIP    Accredited Certified

Martin has suggested the command on 24 February to find tapes expiring on 25 February.

If you execute the command as is on 10 March, it will not find anything.

mph999
Level 6
Employee Accredited

Yes, Marianne makes a good point, you have to change the date as required.

The 'actual command' is correct ...

Martin

NIKHIL234656595
Level 6

BUT I WANT THOSE TAPES WHICH ARE IN THE LIBRARY.

THIS COMMAND GIVES ME THE TAPES WHICH WILL EXPIRE TOMORROW BOTH WHICH ARE OFFSITE AND ONSITE.

 

I want only those tapes which will expire and is onsite.

mph999
Level 6
Employee Accredited

Not sure you can do it from this command, not to get exactly what you want.

You would have to get the tapes that expire 'tomorrow' with the commands we have given, then check these tapes against vmquery -m <media ID>

Eg.

 

root@womble  $ bpmedialist -summary -U |grep expires |grep  03/24/2012
            R0TP01 expires 03/24/2012 16:31
 
(Had to use 03/24, as I have no tapes to expire tomorrow, you use whatever date you wish).
 
Then I use vmquery on each tape I get back ...
 
vmquery -m R0TP01 
 
I can then see if the tape is in the library or not.  This is quite  a manual task, so you can run it in a loop in a script.
 
For example, this script would be a start  (change the date as required)
 
#!/usr/bin/ksh
DATE=03/24/2012
bpmedialist -summary -U |grep expires |grep  $DATE |awk '{print $1}' |while read TAPE
do
if [[ $(vmquery -m $TAPE |grep robot |awk '{print $3}') != NONE ]]
then
echo $TAPE
fi
done
 
Save it to a file eg. /some_path/tape_expire.sh
chmod it
chmod 755 /some_path/tape_expire.sh
 
run it 
 
/some_path/tape_expire.sh
 
Martin
 

NIKHIL234656595
Level 6

i will run it and let u know.

Will_Restore
Level 6

though I would change

  if [[ $(vmquery -m $TAPE |grep robot |awk '{print $3}') != NONE ]]

to

  if [[ $(vmquery -m $TAPE |grep "robot type" |awk '{print $3}') != NONE ]]