tar to tape drive command

I want to use this command to tar to tape:

tar cf - DIR | compress > `hostname`_`date +%m-%d-%y`.DIR.tar.Z

this of course goes to the FS.

How do I modify this to go directly to tape?

My tape device is /dev/rmt/0

thanks.

What OS?

tar cvf /dev/rmt/0 DIR 

I'll also suggest, provided your tar supports it, adding either -z (gzip) or -Z (compress) to have tar do the compression as it writes.

tar cvf /dev/rmt/0 -z DIR 

find . . . -type f | cpio -oaH crc | gzip -9 | dd (help me here).

Tar used to pad files to block size with nulls, wasted media. Luckily, cpio does not, and this gives you complete control over the compression, and multiprocessing.

What do you do when the tape does not read, which old tape is prone to. I thought everyone had gone dvd and network by now.

Sorry,

Solaris 10 with Trusted Extensions.

IMHO (Hope Im wrong...)I doubt you can give a name+extension AND sent to tape all in one...
Either you create a file you copy after to tape...
or
You pipe to tape (but cannot choose to give a name...)

tar cf - DIR | compress | dd of=/dev/rmt/0 

You might want to use dd option "bs=65536" or the like so you write more than 512 bytes a record.

tar will embed nulls in his output even to a pipe to compress unless you use cpio or maybe find an option for tar to stifle most or all of the nulls.

The compress is faster than gzip but twice as big, generally, so gzip or gzip -9 or bzip2 is a better choice. Tape is usually slower than CPU even with bzip2. Play around with the compression level options (bzip2 has a bewildering set), and see what is fast enough. Usually, there is not much difference between gzip -7 and gzip -9, but your data and CPU may vary. Oh, look, rzip, 7zip, . . .

---------- Post updated at 04:48 PM ---------- Previous update was at 04:45 PM ----------

rzip(1): large-file compression program - Linux man page
gzip vs. bzip2 vs. rzip (by Jeremy Zawodny)

---------- Post updated at 05:05 PM ---------- Previous update was at 04:48 PM ----------

PS: If you sort the files from find by extension or file type, you get even better compression! The rzip site says it must have a flat file in -- worried about 32 bit VM space, I guess.