[comp.sys.amiga.tech] Amiga Tape Backups -- my experience

mwandel@bnr-rsc.UUCP (Markus Wandel) (08/12/90)

Every few weeks, this question seems to come up:  "Has anyone written a tape
device driver for the Amiga" -- usually followed by someone answering that
they are working on it.  Well, I've been running a tape backup system on my
machine for a few months now, and maybe I should describe it.

I'm running a homemade SCSI host adapter, supporting the SCSIdirect protocol
as defined in "devices/scsidisk.h".  Connected to the SCSI bus is an Emulex
MT-02 tape controller, which drives a Northern Telecom "Flashback" model
6209-90 tape drive (QIC-36 interface).  The recording format is QIC-24, which
means 9 tracks, 10000 bpi, giving about 1 MB/ 10 ft of tape.  I use DC300XL
cartridges, which are 450 feet and store 45MB.

The first issue was to get the SCSIdirect code to go fast enough to allow the
tape controller to "stream", i.e. run the tape continuously without stopping
and backspacing.  This was barely accomplished, since my interface does not
have DMA.  I used a large buffer (256KB) so the drive can stream for
a significant amount of time while the buffer is read or written.

The tape driver is a DOS handler, acting as a DOS file device on one side, and
talking to the SCSIdirect code on the other.  It is strictly a sequential
access device, and can be opened as "TAPE:", "TAPE:R", and "TAPE:A".  The latter
two forms stand for "rewind" and "append".  Here is how it works:

File name -->  | TAPE:              | TAPE:R             | TAPE:A
---------------+--------------------+--------------------+--------------------
Tape at start  | Start reading or   | Start reading or   | Read: fails
(rewound)      | writing at start   | writing at start   | Write:  Skip to end
               | of tape            | of tape            | of recorded material
               |                    |                    | and start appending
---------------+--------------------+--------------------+--------------------
Tape between   | Read: Skip to next | Rewind, and start  | As above
start and end  | file mark and      | reading or writing | 
of recorded    | read from there    | or writing at      | 
data           | Write: Skip to end | start of tape      |
               | and append         |                    |
---------------+--------------------+--------------------+--------------------
Tape at end of | Read: fails        | As above           | Read: fails
recorded data  | Write: append      |                    | Write: append

The first thing to note is that QIC-24, like lot of other formats, is *not*
random-access, that is, you can not put a file system on the tape at all.  You
can only write at the end of the recorded data, or overwrite the whole tape
from the beginning.  You can not update data in place.

The second thing to note is that the tapes are slow.  Skipping to near the end
of a DC300XL tape means reading eight tracks of 450 feet each, at 90 inches
per second, giving about eight minutes of wait.  On the other hand, the transfer
rate is good -- about 5 MB/minute.

Anyway, so now we have a raw tape device which acts a lot like the rewinding
Unix device driver when accessed as "TAPE:R", and a lot like the non-rewinding
Unix device driver when accessed as "TAPE:".  Multiple files are separated
by file marks.  What is more natural than using the Unix backup program, "tar",
of which an excellent clone is available, free, and already ported to the Amiga.

Using "tar", I can backup my hard disk like this:

	(insert tape)
	mount tape:
	tar cvf tape: dh0:

Even with my primitive SCSI interface, which is used to access the hard disk
and write to the tape and can barely keep up, the backup proceeds at just under
1MB/minute, and since the entire hard disk (partition) fits on a tape, can
proceed unattended.

The resulting backup tape can be restored on a Unix machine, as both the tape
format and the archive format are compatible.  Unix tar tapes can be read on
the Amiga, except that Amiga "tar" blows up on Unix archives with links in
them sometimes.  I've successfully exchanged tapes with an Apollo and a 
MIPS machine.  Amiga tar is excellent, as it stores Amiga-specific information
(protection bits) in a way that it can extract them again, but the Unix tar
does not see them.

So what is the bottom line of this?  When I wrote the TAPE: driver, it was
a hack (start to finish in less than 24 hours) and not written well.  Further-
more, it was targeted at the Emulex MT-02.  But it has worked flawlessly ever
since, and works just as well with a Western Digital ADSI-T100, leading me
to believe that it may be useful to other people.  Also, I have verified that
my SCSIdirect implementation is compatible with Commodore's.

Anyone who wants to try out the TAPE: driver, and a SCSIdirect testing program
that I've also written, should contact me by e-mail.  I offer no guarantees,
not even of a quick response, but I thought I should at least publicize that
I have something working, non-proprietary, and compatible with standards.
If it doesn't work, you had better understand C and the SCSI standard to make
it work, as I won't have time to help -- it works for me.

Happy hacking...

Markus Wandel
uunet!bnrgate!bnr-rsc!mwandel
Working for, but in no way representing, Bell Northern Research