UNIX Checking Tape Space

Hello.

My name is Alex and I am new to the UNIX environment.

One of the things that I do on a daily basis is I perform backups to tape on a Sun Ultra 25. I use DAT72 tape.

The tape that is currently in the tape drive has about five database backups within it already. I was just hoping to find out if there is anyway possible that I can verify how much space is available. Also, how can I find out how big my database file is?

Thanks in advance for those who help me out with this issue.

-Alex

Tape doesn't have a filesystem the way a disk does, everything is contiguous. This means it can't have a filesystem, per se. It's all up to the application... How to tell how much is stored depends on what application you used to store them in the first place.

Oh really? I did not know that. All this time I'm thinking that a file is stored like a song on a regular cassette tape. Whereas if a song only lasts like three minutes or so, the remaining 57 minutes is still available. Obvioulsy, I'm speaking about a 60 minute tape cassette.

So when you mention application, are you asking about a ubackup or ubackups or am I out in left field all alone?

Actually you're exactly right, but consider the implications.

An audio CD has tracks. You can command the CD player to jump to track 12 and it will do so, know how far it jumped, how much is left to play in that track, and where exactly the CD will end. It contains information on its contents... A cassette doesn't -- to find the end you have to listen to it. The 'end' might not even be silence, just old music you no longer care about, so you have to pay attention too.

Figuring this out is what a filesystem does for you and a tape doesn't. That often but not always becomes the tape application's job. It's also possible to just use a tape raw, with nothing but you keeping track of where its valid contents start and end.

By 'application', I'm asking exactly what you type or click to make a backup happen.

Thanks for the file system explanation.

When I perform the backups, I use a different tape for every day of the week. For example, I'll use the same tape for Monday. I'll use another tape for every Tuesday. And, so on.

Most of the work that I do is through the console. I type:

su - ubackups

When prompted, I enter my password.

I'm then brought to the backup/restore menu. I enter my options to ensure I perfrom a backup to tape. Once I'm done with that, I then tar the file using the tvf options. I attempted to read the man pages for the tar options but that's like rubbing my sandpaper into my eyes.

Okay, third time lucky...

It would be useful to know what you did in that backup application, what you typed into tar, not just that you did so.

Unfortunately ubackups is not an application I am familiar with, I cannot find any reference to it on the internet, but hopefully your tar commandline will be more enlightening. 'tar' stands for 'tape archiver' and it's possible that most of what's happening is done by it.

Okay.

Once I'm done with the tape backup, I use:

tar tvf /dev/rmt/0

Okay, that tells me a lot. :slight_smile: Your "ubackups" program is probably a custom script, but it just uses tar to write to the tape...

Scan to the end of the tape with

tar tvf /dev/rmt/0n

0n is the same tape device but non-rewinding: It leaves the tape where it finished when tar is done. This lets you do mt -f /dev/rmt/0n tell to tell you the current position of the tape (probably in blocks of 512, not bytes, though other blockisizes are possible) and figure out exactly how much has been stored on it.

Then you can mt -f /dev/rmt/0n rewind to rewind the tape.

1 Like

Sweet! Thank you so much! On my way to try it now.

The 'tvf' options just list a tar's contents, by the way. tar has accumulated a lot of cruft over the years but in the end it does just a few basic things:

# Create a tar archive.  Your backup application probably does this.
tar cf /path/to/archive list of files and directories to include
# Append to an existing tar archive.  Your backup application might do this.
tar rf /path/to/archive list of files and directories to include
# Extract a tar archive or part of a tar archive.
tar xf /path/to/archive [optional list of files to extract]
# List the contents of a tar archive without extracting them.
tar tvf /path/to/archive

'archive' can mean either file or tape -- tar uses them the same way.

The 'v' in tvf stands for verbose, which means 'print more information' -- 'xvf' would print filenames as it goes when 'xf' would not. It might be redundant for 't' but doesn't hurt either.

The /dev/rmt/0 rewinds the tape after the operation.
Your previous backup is overwritten.
But it is easy to restore.
/dev/rmt/0n device enables you to append another backup file.
But in order to restore a certain file you need to use the mt commands

mt -f /dev/rmt/0n tell
mt -f /dev/rmt/0n fsf 1 # advance to the next file
mt -f /dev/rmt/0n bsf 1 # go backwards to the previous file
mt -f /dev/rmt/0n rewind # rewind to the beginning

Again that depends on what his backup application is doing. It might be using these commands already.

When I use tar tvf /dev/rmt/0n, I can see all the backups I have done. I have about six backups in a tape that I use only for Fridays. If you remember, I mentioned earlier that I use one tape for each day of the week.

However, when I attempted to input mt -f /dev/rmt/0n tell, my system did not recognize the command. Am I using the wrong syntax or is it possible that not all Unix machines have the same abilities as others?

All UNIX is indeed not identical but mt ought to be available for Solaris... I was reading a Solaris manual page to figure out instructions for it. A few possibilities:

1) Maybe it's not in your PATH. 'whereis mt' or 'whence mt' may give you an absolute path to it, and then you can run it like /absolute/path/to/mt

2) It might not be installed.

You are right, Solaris does not have "mt tell".
Maybe only Linux has it? Its man page also states it does not work with all tapes.
In this case you must do your own book-keeping...

Funny, that's where I found it. He may be having trouble finding mt though.

And you are right, too: Solaris 11 has it.
I only checked Solaris 10.

I will check as soon as I return to work tomorrow.

Are there any available UNIX ISOs? I use Virtual Machine Player. I currently have a Linux build on there. I believe it is called Lovelace or Lovelock.

My apologies. Solaris is not my forte. Surely it must have other tools for managing the tape but I don't know... I'm going to move this into the Solaris forum where you might get better answers.

BSD is a popular "true" UNIX for x86 machines. There's also an OpenSolaris these days, or whatever descended from it.

Hmmm, here's another way you could try it.

dd if=/dev/rmt/0 | tar vtf -

dd may complain about tar forcing it to quit early but that's exactly why we pipe it into tar, to kill it when the archive ends, not when the tape ends. dd should print rough statistics on how much was read, in blocks of 512, once it is done...