Operating System - HP-UX
1834140 Members
2872 Online
110064 Solutions
New Discussion

One liner to find a device file for DDS

 
SOLVED
Go to solution
Q4you
Regular Advisor

One liner to find a device file for DDS

Folks,

looking for a one/two liner or awk script to find DDS tape drive's device file to use in one of the script for Ignite Backups..


Thanks
15 REPLIES 15
MANOJ SRIVASTAVA
Honored Contributor

Re: One liner to find a device file for DDS

ioscan -fnC tape | grep rmt |awk '{print $1}'


Manoj Srivastava
Q4you
Regular Advisor

Re: One liner to find a device file for DDS

Thanks Manoj, but there is more to it...

I have 10 rmts on the systems DLT4000s, DLT7000s etc. I just need a device file for *DDS HP1537 or HP1533* Tape drive.

Basically, I want to do this ->

DDS="command to get DDS dev file"

make_recovery -Av -d {DDS}
harry d brown jr
Honored Contributor

Re: One liner to find a device file for DDS


What are you going to do if you have TWO dds tape drives?

This is not something you ONELINE/TWOLINE. Do not leave your SYSTEM BACKUP to "CHANCE", make it absolute!

Of course make_recovery is also obsolete.

OR, what are you going to do if your "single" DDS tape drive is broken? Change your script in production to backup to a DLT?

live free or die
harry
Live Free or Die
MANOJ SRIVASTAVA
Honored Contributor

Re: One liner to find a device file for DDS

that is why i did put a awk this will print the frist column you can use a combination of grep and aek to get the right device fiel , incase you are not able to suceed just post the o/p of ioscan ifnc tape and the device fiel u wnat to use and I will give you the right espression , infact we ahve a SAN Legato wiht more that 14 viraul drive per amchine on a 12 drive 60 slot library.


Manoj Srivastava
harry d brown jr
Honored Contributor

Re: One liner to find a device file for DDS

Manoj,

I totally agree with your approach. I find it very dangerous to script such an IMPORTANT backup with blinders on -> basically hard coding tape drives.

live free or die
harry
Live Free or Die
Q4you
Regular Advisor

Re: One liner to find a device file for DDS

Class I H/W Path Driver S/W State H/W Type Description
=====================================================================
tape 1 8/16/5.1.0 stape CLAIMED DEVICE HP C1533A
/dev/rmt/1m /dev/rmt/c1t1d0BESTn
/dev/rmt/1mb /dev/rmt/c1t1d0BESTnb
/dev/rmt/1mn /dev/rmt/c1t1d0DDS
/dev/rmt/1mnb /dev/rmt/c1t1d0DDSb
/dev/rmt/c1t1d0BEST /dev/rmt/c1t1d0DDSn
/dev/rmt/c1t1d0BESTb /dev/rmt/c1t1d0DDSnb
tape 2 8/16/5.4.0 stape CLAIMED DEVICE HP C1533A
/dev/rmt/2m /dev/rmt/c1t4d0BESTn
/dev/rmt/2mb /dev/rmt/c1t4d0BESTnb
/dev/rmt/2mn /dev/rmt/c1t4d0DDS
/dev/rmt/2mnb /dev/rmt/c1t4d0DDSb
/dev/rmt/c1t4d0BEST /dev/rmt/c1t4d0DDSn
/dev/rmt/c1t4d0BESTb /dev/rmt/c1t4d0DDSnb
tape 3 8/16/5.5.0 stape CLAIMED DEVICE Quantum DLT4000
/dev/rmt/3m /dev/rmt/c1t5d0BEST
/dev/rmt/3mb /dev/rmt/c1t5d0BESTb
/dev/rmt/3mn /dev/rmt/c1t5d0BESTn
/dev/rmt/3mnb /dev/rmt/c1t5d0BESTnb

Q4you
Regular Advisor

Re: One liner to find a device file for DDS

Sorry forgot to add..

I wish to use the first DDS that appears in ioscan ( in above example which is at 1m)

Why we do this ?

We have some 50 HP systems which are standardized with DDS(2/3/4) tape drives and all our ignites are done to DDS ( for simplicity and media mgmt)

We just want to put this in crontab and not to worry about customizations.

Thanks !
Rodney Hills
Honored Contributor

Re: One liner to find a device file for DDS

Rather than using ioscan each time, which might not necesarily always be consistent each time it is run. I think defining a link to the device you want to use should be created.
eg-
ln /dev/rmt/1m /dev/tape.ignite

Do this on each of your systems and use /dev/tape.ignite in your scripts.

Hope this helps...

-- Rod Hills
There be dragons...
harry d brown jr
Honored Contributor

Re: One liner to find a device file for DDS

Q4,

We manage over 400 HP 9000's, and now almost 100 sun sick-laris boxes. The HP 9000 boxes have make_tape_recovery's made at least once a week-month, but it doesn't make sense to LOCK down a tape drive to it, especially in case it fails. Our operators are trained to use the next available drive. If you want to automate such an IMPORTANT backup, then why not just create a CONFIGURATION file, and put the tape drive that THAT server would use for make_tape_recovery's. THAT WAY, if the TAPE DRIVE FAILED, you could easily modify the CONFIGURATION file and recreate the make_tape_recovery!

For 50 machines this is TOO EASY.

live free or die
harry
Live Free or Die
Q4you
Regular Advisor

Re: One liner to find a device file for DDS

Guys,

understand the importance of the Ignite, will never want to leave it to a chance. My script will have various error handling conditions & checks and Email notification in case Ignite fails or does not start. This same script will be either copied to all the servers or NFS mounted, so it needs some "intelligence" to find DDS device for each system.


My original Q is ->


Define DDS variable for DDS tape drive C1533, C1537 or C5683A ( Most systems have one DDS, but may have many DLTs hence many rmt files)


DDS="command to get a claimed DDS dev file"

make_recovery -Av -d ${DDS}
Rodney Hills
Honored Contributor

Re: One liner to find a device file for DDS

If you for wanted the first /dev/rmt file following the first DDS, then you can do this-

ioscan -fnC tape | awk '/C1533|C1537|C5683A/{getline; print $1; exit}'

I've had ioscan's though that did not have the proper tape device as the first entry, so here is another call that looks for /dev/rmt/#m.

ioscan -fnC tape | perl -ne '/C1533|C1537|C5683A/ && do {$dds=1;} ; if ($dds and /(\/dev\/rmt\/\d+m\s*)/) { print $1,"\n"; exit}'

Good Luck... (although I think my original recommendation was safer...)

-- Rod Hills
There be dragons...
Rodney Hills
Honored Contributor

Re: One liner to find a device file for DDS

If you for wanted the first /dev/rmt file following the first DDS, then you can do this-

ioscan -fnC tape | awk '/C1533|C1537|C5683A/{getline; print $1; exit}'

I've had ioscan's though that did not have the proper tape device as the first entry, so here is another call that looks for /dev/rmt/#m.

ioscan -fnC tape | perl -ne '/C1533|C1537|C5683A/ && do {$dds=1;} ; if ($dds and /(\/dev\/rmt\/\d+m\s*)/) { print $1,"\n"; exit}'

Good Luck... (although I think my original recommendation was safer...)

-- Rod Hills
There be dragons...
Rodney Hills
Honored Contributor

Re: One liner to find a device file for DDS

If you for wanted the first /dev/rmt file following the first DDS, then you can do this-

ioscan -fnC tape | awk '/C1533|C1537|C5683A/{getline; print $1; exit}'

I've had ioscan's though that did not have the proper tape device as the first entry, so here is another call that looks for /dev/rmt/#m.

ioscan -fnC tape | perl -ne '/C1533|C1537|C5683A/ && do {$dds=1;} ; if ($dds and /(\/dev\/rmt\/\d+m\s*)/) { print $1,"\n"; exit}'

Good Luck... (although I think my original recommendation was safer...)

-- Rod Hills
There be dragons...
Rodney Hills
Honored Contributor
Solution

Re: One liner to find a device file for DDS

If you for wanted the first /dev/rmt file after the first DDS, then you can do this-

ioscan -fnC tape | awk '/C1533|C1537|C5683A/{getline; print $1; exit}'

I've had ioscan's though that did not have the proper tape device as the first entry, so here is another call that looks for /dev/rmt/#m.

ioscan -fnC tape | perl -ne '/C1533|C1537|C5683A/ && do {$dds=1;} ; if ($dds and /(\/dev\/rmt\/\d+m\s*)/) { print $1,"\n"; exit}'

Good Luck... (although I think my original recommendation was safer...)

-- Rod Hills
There be dragons...
Q4you
Regular Advisor

Re: One liner to find a device file for DDS

Rod, Thanks !

tried both of them.

I will not use perl version of the "one liner" as some systems may need perl install.
And it needed a small correction -> "and" replaced with &&

So what I got I was looking for. So you get 10. But, I can't give you 4 times 10 :) !