Video Screencast Help

How to create a script using 'vmchange -barcode' to add either L4 or L2 to the end of the barcode label

Created: 02 Jan 2010 • Updated: 15 Jul 2010 | 19 comments

Hi
Looking for help. My tape library seems to read the barcodes wrongly some are read as GAT200L4 or GAT100L2 whilst others are read as GAT200 or GAT100. Due to this issue the library complains there are no scratch tapes even though I have just added some and inventoried the library. I have about 300 existing tapes with this anomaly.
Now that I have a barcode rule in place to read them with the 'L4' or 'L2' appended. I want to create a script using 'vmchange -barcode' to add either L4 or L2 to the end of the barcode label. For example, if the barcode label is GAT200, I will like it to be GAT200L4.

Comments 19 CommentsJump to latest comment

Sriram's picture

1.  Get a list of barcode lables you want to change and save it in a file called /tmp/barcode.labels.change

2.  Using step 1 file as master file write a shell script as follows:

Line 1 #!/bin/sh
Line 2 for i in `cat /tmp/barcode.labels.change`
Line 3 do
Line 4 LABEL=`echo $i |sed -e '1s/$/L4/'`
Line 5 /usr/openv/volmgr/bin/vmchange -barcode $LABEL
Line 6 done

3.  Step 2 will read all the lines from step 1 file, edit L4 at the end of each line, execute vmchange -barcode command for each line.

Note: you need to change L4 to L2 (whatever you wish) in Step 2 Line 4 and execute it again.

This will 100% work perfectly.

Enjoy !!!!!

sokam's picture

Hi Sriram,

Thanks for the response.
Unfortunately my knowledge of writing a shell script is non-existent and I operate in a Windows environment.
Can you please explain further on how I can:
1 write/executive this script ?
2. where to run it from?
3.  do I need any other additional software on my master server  to run the script
4.. any other additional information will be great.

Sorry for my zero knowledge on shell scripting

Thanks

Sriram's picture

This is a shell script for UNIX master environment.

Which environment your master is in ?

pkh's picture

sokam,

Do your physical barcode labels have the L2 and L4 suffixes?  If they have them, then the next time the tapes are used, their media labels, i.e. internal labels, would be changed to match the barcode labels.

sokam's picture

Yes the physical barcode labels do have the L2 and L4 suffixes. I have now decommissioned my LTO2 library so the L2 tapes are not used for backups anymore. So the only time the L2 tapes will be used is when I need them for restore which at the moment is unlikely.
The L4 tapes are actively being used and want to be able to differentiate between the L2 and L4 when recalling tapes from my off-site tape location.

Sriram's picture

Can you send me the screen shot of the existing barcode rule you have setup and the labels in the netbackup.

Sriram's picture

So from this screen shot it seems that only tape ids starting from OXF barcode labels ending with L2 or L4

Can you send me the vm.conf entries from master and the "Media ID Generation" tab screen shot.

 

sokam's picture

DEVICE_HOST = netbkmaster
SCRATCH_POOL = Scratch
DEVICE_HOST = netbkmedia01
DEVICE_HOST = netbkmedia02

MM_SERVER_NAME = netbkmaster
MEDIA_ID_BARCODE_CHARS = 1 8 1:2:3:4:5:6
MEDIA_ID_BARCODE_CHARS = 2 8 1:2:3:4:5:6
MEDIA_ID_BARCODE_CHARS = 3 8 1:2:3:4:5:6
MEDIA_ID_BARCODE_CHARS = 4 8 1:2:3:4:5:6
MEDIA_ID_BARCODE_CHARS = 0 8 1:2:3:4:5:6

Not sure whether the entries in the vm.conf is right - because DEVICE_HOSTs netbkmedia01 and 02 are the LTO2 tape libraries which I have de-comissioned. The new DEVICE_HOSTs for the LTO4 libraries are not  listed. Is that  expected?

media_generation_tab.JPG

Sriram's picture

1. To which device host your media ids OXG and OXF are assigned to?

2. Why is your "Media Type = HCART2" for L2 and L4.  OXG183L2 and all others? 

You should not set same density for two different media types.

3.  Can you tell me to which robot OXG and OXF tape series are assigned to?

4.  What happend to the media which were assigned to the decommissioned host and what are their series?

5.  What are the media series GAT which you mentioned in the begining, to which device hots they are assigned, what are their density and why you have not mentioned GAT series in the barcode rules tab?

If you have decommissioned any device host please remove it from vm.conf file

sokam's picture

Please see my response in bold - (wanted to use a different colour but it wasn't available)

1. To which device host your media ids OXG and OXF are assigned to?
MEDIASERVER01 and 02

2. Why is your "Media Type = HCART2" for L2 and L4.  OXG183L2 and all others? 
I still have some data on the LTO 2 tapes that in future I may want to restore using the LTO4 drives

>>You should not set same density for two different media types.
Can you please explain why or provide an alternative solution?

>>3.  Can you tell me to which robot OXG and OXF tape series are assigned to?
Presently assigned to the LTO4 tape libraries

>>4.  What happend to the media which were assigned to the decommissioned host and what are their series?
They have been inherited by the new hosts (LT04 tape libraries)

>>5.  What are the media series GAT which you mentioned in the begining, to which device hots they are assigned, what are their density and why you have not mentioned GAT series in the barcode rules tab?
CAT is used for catalog backups

>>If you have decommissioned any device host please remove it from vm.conf file
OK will do. But as mentioned previously the new device host are listed in the vm.conf file. Any idea why?

Sriram's picture

sokam,

after researching i found a way you can adopt to change the barcode for multiple anamolies you have:

1.  list down the media ids and copy it to MS EXCEL in column A

2.  in column "B1" of the spreadsheet type this formula

=CONCATENATE("vmchange.exe -barcode ",A1,"L4"," -m ",A1) and press ENTER

and your output in column B1 will be like this

vmchange.exe -barcode GAT100L4 -m GAT100

3.  copy column B1 and paste it to rest of rows starting from B2 to B300.  This will result in output being subsequently changed as above with media id mentioned in column A.

4.  Now you can change L4 to L2 where ever required.

5.  After you have the desired output in column B then copy all the contents of column B1 to B300 and paste it to a notepad.

6.  Now save the notepad with ".BAT" extension

7.  Now you can execute the batch file to change all the 300 media id barcodes.

Hope this helps

sokam's picture

Thanks  very much Sririam.
I try your suggested solution and let you know how I get on.

Sriram's picture

>>You should not set same density for two different media types.
Can you please explain why or provide an alternative solution?
ANS: you will end up in density mismatch.  If you are not going to use LTO2 tapes for backup freeze them keep it aside, unfreeze and reuse them when you need to restore.

>>3.  Can you tell me to which robot OXG and OXF tape series are assigned to?
Presently assigned to the LTO4 tape libraries
ANS: I meant the robot number which you have mentioned in the media id generation screenshot

>>4.  What happend to the media which were assigned to the decommissioned host and what are their series?
They have been inherited by the new hosts (LT04 tape libraries)
ANS:  As a best practice when you decommission a media server either you should change the owner to other device host/master or if the tapes are not being used any more you can remove them from the library

>>5.  What are the media series GAT which you mentioned in the begining, to which device hots they are assigned, what are their density and why you have not mentioned GAT series in the barcode rules tab?
CAT is used for catalog backups
ANS: At the very begining of your post you mentioned GAT200L4 what are those and why you have not included GAT series in the barcode rule

>>If you have decommissioned any device host please remove it from vm.conf file
OK will do. But as mentioned previously the new device host are listed in the vm.conf file. Any idea why?
ANS:  As part of netbackup media server decommission you need to remove traces of the server from netbackup.