Veritas-bu

Re: [Veritas-bu] How can I get a count of tapes that have a retention of more than 1 year?

2015-07-31 09:59:14
Subject: Re: [Veritas-bu] How can I get a count of tapes that have a retention of more than 1 year?
From: "Lightner, Jeff" <JLightner AT dsservices DOT com>
To: nbuser <nbuser AT rediffmail DOT com>, "WBedour AT lear DOT com" <WBedour AT lear DOT com>
Date: Fri, 31 Jul 2015 13:59:21 +0000

bpmedialist –U gives 2 lines of output for each tape.

 

Based on the hint however I found bpmedialist –l gives a single line and wrote the following script.  If you cut and paste it into a file on your RHEL system and set permissions to execute it this should output what you want.

 

It also has a fair amount of detailed comments in it so it could be used to get similar information by modifying some of the variables.

 

v v v START OF SCRIPT v v v

#!/bin/bash

 

# Script to get all media that expires 1 year or longer from now

 

# 31-Jul-2015 jlightner - Initial write

 

# Input is used from bpemedialist -l (as it gives one line per media).

 

# Sample record from bpmedialist -l:

#DS0829 *NULL* 1 14 1434682810 1434682810 2147483647 0 20492256 1 1 9 4 0 0 1024 0 320196 0 0 0 0 0 0 0 0

 

# Fields as defined in man page:

#media_id partner_id version density time_allocated time_last_written time_of_expiration time_last_read Kbytes nimages vimages_unexpired_images retention_level volume_pool number_of_restores status hsize ssize l_offset reserved psize reserved four reserved fields

# NOTE:  The above is all one line starting with the “#” – if you cut and paste from email make sure this is the case in your script.

 

# Breakdown of fields of above sample based on man page:

#media_id partner_id version density time_allocated time_last_written

#DS0829  *NULL*     1       14      1434682810     1434682810

#

#time_of_expiration time_last_read Kbytes   nimages vimages_unexpired_images

#2147483647         0              20492256 1       1

#

#retention_level volume_pool number_of_restores status hsize ssize l_offset

#9               4           0                  0      1024  0     320196

#

#reserved psize reserved reserved reserved reserved reserved UNKNOWN

#0        0     0        0        0        0        0        0

#END OF BREAKDOWN

 

# Note the times above are in Epoch (a/k/a Unix time, Posix time) which makes

# them easy to sort by.

 

#epdate=$(date +%s) # Not used but noted - this will output current Epoch time.

datey=$(date +%Y)   # Current 4 full year (e.g. 2015)

datemd=$(date +%m%d)# Current MMDD (e.g. 0731)

nextyr=$(($datey + 1)) # Determine next year by adding 1. (e.g. 2015 + 1 = 2016)

nextdt=${nextyr}${datemd} #Next year in YYYYMMDD (e.g. 20160731)

nextep=$(date +%s -d $nextdt) # Epoch version of next year (e.g 1469937600)

 

# Now do a while loop on the output of bpmedialist -l, assigning the first 7

# fields as defined by man page then assigning everything else to a final "rest"

# variable since we won't use anything beyond the first 7.

#

# Key variables assigned here are "mid" which is Media ID and tm_exp which is

# the expiration date (in epoch)

#

# The loop will firs sort the output of bpmedialist by the expiration date field

# then will only output the Media ID and the Expiration date for those tapes

# that have an expiration greater than or equal to one year from today.

 

bpmedialist -l |sort -nk7 |while read mid pid ver dens tm_all tm_writ tm_exp rest

do if [[ $tm_exp -ge $nextep ]]

   then calexp=$(date -d @$tm_exp)

        echo $mid $calexp

   fi

done

^ ^ ^ END OF SCRIPT ^ ^ ^

 

Jeffrey C. Lightner

Sr. UNIX/Linux Administrator

 

DS Services of America, Inc.

2300 Windy Ridge Pkwy

Suite 600 N

Atlanta, GA  30339-8461

 

P: 678-486-3516

C: 678-772-0018

F: 678-460-3603

E: jlightner AT dsservices DOT com

 

From: veritas-bu-bounces AT mailman.eng.auburn DOT edu [mailto:veritas-bu-bounces AT mailman.eng.auburn DOT edu] On Behalf Of nbuser
Sent: Thursday, July 30, 2015 11:58 PM
To: WBedour AT lear DOT com
Cc: veritas-bu AT mailman.eng.auburn DOT edu
Subject: Re: [Veritas-bu] How can I get a count of tapes that have a retention of more than 1 year?

 

Run command "bpmedialist -U"

On Fri, 31 Jul 2015 00:15:08 +0530 "BeDour, Wayne" wrote
>







I’m currently running NetBackup 7.6.0.1 on Redhat Linux. I admit, I’m taking the quick easy way out on
this but I need an answer kind of quick. Is there a way I can get a count of tapes that have a
retention of more than 1 year?
Thanks in advance…

Wayne BeDour
Unix System Administrator
PH: 248-447-1739
Internet: wbedour AT lear DOT com





**********************
** LEGAL DISCLAIMER **
**********************

This E-mail message and any attachments may contain
legally privileged, confidential or proprietary
information. If you are not the intended recipient(s),
or the employee or agent responsible for delivery of
this message to the intended recipient(s), you are
hereby notified that any dissemination, distribution
or copying of this E-mail message is strictly
prohibited. If you have received this message in
error, please immediately notify the sender and
delete this E-mail message from your computer.
_______________________________________________

Veritas-bu maillist - Veritas-bu AT mailman.eng.auburn DOT edu

http://mailman.eng.auburn.edu/mailman/listinfo/veritas-bu

 

Get your own FREE website, FREE domain & FREE mobile app with Company email.  

Know More >

 

_______________________________________________
Veritas-bu maillist  -  Veritas-bu AT mailman.eng.auburn DOT edu
http://mailman.eng.auburn.edu/mailman/listinfo/veritas-bu