Backup & Recovery

This article is a follow-up to this article
If you are using BE 2012, you would find that you are no longer able to set barcode rules using the GUI.  You have to use BEMCLI instead.  Essentially, the steps are the same as before when you are using the GUI, but there are a few more steps to get the media types, etc. because you are now using the command-line.
To recap, you use barcode rules to prevent the accidental writing or reading of the wrong type of tapes in the wrong tape drive.
I will use the same example as in the previous article to show how to setup barcode rules using BEMCLI.  To run BEMCLI, go to Start > All Programs > Symantec Backup Exec > Backup Exec Management Command Line Interface.

1) List the LTO media types

From the BEMCLI console, issue this command
Get-BEMediatype | Where-Object {($ -like "LTO*")} | Select-Object name
This will give you a list of media types
LTO CLN                                                                                            
LTO-10 (87m, 10.0GB)                                                                               
LTO-30 (203m, 30.0GB)                                                                              
LTO-50 (319m, 50.0GB)                                                                              
LTO-100 (609m, 100.0GB)                                                                            
LTO2 (609m, 200.0GB)                                                                               
LTO3 (680m, 400.0GB)                                                                               
LTO4 (820m, 800.0GB)                                                                               
LTO [10]                                                                                           
LTO [11]                                                                                           
LTO [12]                                                                                           
LTO [13]                                                                                           
LTO [14]                                                                                           
LTO [15]                                                                                           
LTO [16]                                                                                           
LTO [17]                                                                                           
LTO [18]                                                                                           
LTO [19]                                                                                           
LTO [20]                                                                                           
LTO [21]                                                                                           
LTO [22]                                                                                           
LTO [23]                                                                                           
LTO [24]                                                                                           
The command above filters for only LTO media types.  If you have upgraded to BE 2012 from an earlier release, you would not see the LTO5 and LTO6 media types.  You would see something like this instead
LTO3 (680m, 400.0GB)                                                                               
LTO4 (820m, 800.0GB)                                           
LTO [8]                                                                                          
LTO [9]             
LTO [10]
So you would have to use another media type to represent LTO5, e.g. LTO [8]
If you want to see all the media types, then issue

2) Add the barcode rules for LTO4 and LTO5

First check whether there are any rules defined for your vendor by issuing this command
Get-BEBarcodeRule | Where-Object {($_.vendor -eq "HP")}
In this example, we check for HP.  This command will return nothing if there are no barcode rules for HP or it may return something like the following
Vendor                   BarcodePrefix     BarcodeSuffix      MediaType               
------                       -------------            -------------             ---------               
HP                                                  L5                       LTO [8]                 
HP                                                  L2                       LTO2 (609m, 200.0GB)    
HP                                                  L4                       LTO4 (820m, 800.0GB)    
If you want to see all the barcode rules, then just issue 
If you have a fresh install of BE 2012, then you would get this
Vendor   BarcodePrefix   BarcodeSuffix   MediaType
------        -------------          -------------          ---------
              CLN                                        CLN
                                     L1                    LTO-100
                                     L2                    LTO2
                                     L3                    LTO3
                                     LT                    LTO3
                                     LU                    LTO4
                                     L4                    LTO4
                                     L5                    LTO5
                                     LV                    LTO5
                                     LW                   LTO6
                                     L6                    LTO6
If your tape vendor's barcode label format conforms to the above then you can skip the next step if you want to.

3) Define the barcode rules

Suppose there are no barcode rules defined for HP LTO4 and LTO5.  Issue these commands to add the barcode rules.
New-BEBarCodeRule -mediatype "LTO4" -vendor "HP" -barcodesuffix "L4"
New-BEBarCodeRule -mediatype "LTO5" -vendor "HP" -barcodesuffix "L5"
If your vendor's barcode label format calls for the prefix to be used, then the above command would look something like this
New-BEBarCodeRule -mediatype "LTO5" -vendor "VendorA" -barcodeprefix "L5"
If you are using another media type as a substitute for LTO5, then your command would look something like this
New-BEBarCodeRule -mediatype "LTO [8]" -vendor "HP" -barcodesuffix "L5"

4) Get the name of your robotic library

Issue this command to get your robotic libraries

5) Get the names of your tape drives

Assuming that you have one robotic library
Get-BERoboticLibraryDevice | Get-BETapeDriveDevice
Suppose the that the first tape drive is a LTO4 tape drive and the second (or last) tape drive is a LTO5 tape drive.  Issue the following commands
$lto4tapedrive = Get-BERoboticLibraryDevice | Get-BETapeDriveDevice | Select-Object -first 1
$lto5tapedrive = Get-BERoboticLibraryDevice | Get-BETapeDriveDevice | Select-Object -last 1

6) Set the read/write media types

By default, all the available media types are set as readable and writable for each tape drive.  If you want to specify that the tape drive can only read/write some media types, but not all, then you would have to replace the default list with the readable/writable media types.   You got to replacing the list of writable media types first.  This is because when a media type is writable, it implies that it is readable.
For the LTO4 tape drive, issue the following command
Set-BETapeDriveDevice -in $lto4tapedrive -WritableMediaType LTO4, LTO3 -ReadableMediaType  LTO2 
The above command adds LTO4 and LTO3 as the list of writable media types.  This also implies that LTO4 and LTO3 are readable media types. It then add LTO2 as an additional readable media type.  You can also set the readable and writable media types seperately, e.g.
Set-BETapeDriveDevice -in $lto4tapedrive -WritableMediaType LTO4, LTO3
Set-BETapeDriveDevice -in $lto4tapedrive -ReadableMediaType  LTO2 
If you do want to do the readable and writable media types seperately, remember to do the writable media types before you do the readable media types.
Each time you run the above commands to set the readable/writable media types, you got to supply the entire list of media types.  The existing list of media types would be overwritten.  Whichever media types that is not on the list is NOT readable/writable by that tape drive.
Similarly, for the LTO5 tape drive, issue the following commands
Set-BETapeDriveDevice -in $lto5tapedrive -WritableMediaType LTO5, LTO4 -ReadableMediaType  LTO3 
Suppose you only want the LTO4 and LTO5 tape drives to read/write only LTO4 and LTO5 tapes respectively.   You would issue these commands.
Set-BETapeDriveDevice -in $lto4tapedrive -WritableMediaType LTO4
Set-BETapeDriveDevice -in $lto5tapedrive -WritableMediaType LTO5
As before, by implication, the LTO4 tape drive can read LTO4 tapes and LTO5 tape drive can read LTO5 tapes.
In the above commands, if you are using another media type as a substitute for LTO5, e.g. LTO [8], then enclose substitute LTO5 with "LTO [8]".  Note the double quotes.
You can check what media types are readable/writable by issuing these commands
$lto4tapedrive | Select-Object Name,@{n="WritableMedia"; e={$_ | Get-BEMediatype -writablemedia}},@{n="ReadbleMedia"; e={$_ | get-bemediatype -readablemedia}}| format-table -wrap -autosize
$lto5tapedrive | Select-Object Name,@{n="WritableMedia"; e={$_ | Get-BEMediatype -writablemedia}},@{n="ReadbleMedia"; e={$_ | get-bemediatype -readablemedia}}| format-table -wrap -autosize

7) Enable barcode rules for your library

If you have more than one robotic library, then you would have to use the Where-Object cmdlet to filter for the correct library. Otherwise, issue this command to enable barcode rules for your robotic library
Get-BERoboticLibraryDevice | Set-BERoboticLibraryDevice -BarcodeRulesEnabled $true
If there is anything wrong, you can turn off the barcode rules by issuing this command.
Get-BERoboticLibraryDevice | Set-BERoboticLibraryDevice -BarcodeRulesEnabled $false

Thanks for the Great post.  I did have a few changes I had to make to get the commands to run.  

ran this for each drive 1-4 

$lto4tapedrive = Get-BERoboticLibraryDevice | Get-BETapeDriveDevice -name "Drive #1*"
Then ran this for the LTO 4 Drives:
Set-BETapeDriveDevice -in $lto4tapedrive -WritableMediaType LTO4*, LTO3* -ReadableMediaType  LTO2* 
or this for the LTO 5 drives:
Set-BETapeDriveDevice -in $lto4tapedrive -WritableMediaType "LTO [8]", LTO4* -ReadableMediaType  LTO3* 

Working another case and I could not find a way to edit the existing rule.  I had to delete it and readd it to get it configured the way I wanted. Once again, it was the asterisk * after LTO 4 that allowed the command to succeed.


To delete an existing barcode rule, first get the rule you want to edit, then pipe it to remove-bebarcoderule.  

GET-BEBarcodeRule -barcodeprefix 0011 | Remove-BEBarcodeRule

Next add the rule back in with the desired settings:

New-BEBarCodeRule -mediatype "LTO4*" -vendor "HP" -barcodeprefix "0011" -barcodesuffix "L4"


If the BE 2012 installation is an upgrade from earlier version of BE, then there is no LTO5 media type.  You got to use a dummy LTO type to represent LTO5, like what you did.

There is no way to edit a barcode rule.