Colorado 5GB IDE Tape Drive in Linux
The first thing to note is there are two devices created if your tape drive is detected. There is a /dev/ht0 and a /dev/nht0. The first one, when used, will rewind the tape to the beginning after every command to it. The later, will leave the tape at its current position. If you want to work with non rewinding tape drives, to store multiple files and be able to get to each of them, then this probably won't help you much.
I am strictly interested in backup up a single filesystem to a tape, and overwriting anything that was on there. I prefer software compression (gzip in this case), so I don't really deal with the hardware density and compression settings, but it's pretty easy to do.
Anyhow, here's the current backup script I'm using. If I forget to take a tape out, it will overwrite what's on there, which in reality, isn't that big of a deal to me. This is not my only method for backup, but is mainly just another level of precausion. So stick this somewhere and run it as a cron job sometime when you arn't trying to sleep because this particular tape drive makes a good bit of noise.
#!/bin/sh # # Copyright (C) 2004, J.D. Henderson <www.digitalpeer.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # This is a simple backup script for my Colorado 5GB internal tape drive. # Simply uses tar with software gzip compression. # # Theory... # It's just stupid to backup multiple tape files or use anything other than a # full backup on a tape drive these days so that's all this script does. The # drive doesn't eject so if you slap this in crontab (like me) and forget to # swap the tapes out it will simply overwrite what's on there. # if [ $# -lt 1 ] then echo "usage: $0 <directories>" exit; fi # The device to use. # I am only interested in the rewinding device DEVICE=/dev/ht0 # The directories to backup DIRECTORIES=$1 # # Make sure i've got a damn tape in the drive. # if ( ! mt -f $DEVICE status ) then echo "No tape in drive." && exit 1 fi # # Actually do the backup now, and time that sucker so I can monitor how # long it's taking. # echo Starting at `date` ... time tar -c --totals -z -f $DEVICE $DIRECTORIES echo Ending at `date` exit 0 Now, here's what you'll need to know if you wanna see what's on a tape: tar tvfz $DEVICE And, here's what you'll need to know if you wanna extract it all: tar xvfz $DEVICE
If you have an IDE tape drive, and it's failing, you may need to turn off DMA access. I had to do this otherwise I got an I/O error on any command to the drive. You can disable DMA with the command:
hdparm -d 0 /dev/hdd
You can look at startup to see what drive id your IDE tape drive is detected as.