Backing Up In Linux

Want to start backing up your Linux system properly, but don't know what's available to do the job? Yusuf Nagree helps you configure and use available backup hardware.
Making Devices

Next, you need to make sure that the SCSI devices have been created in your /dev directory. Once again, if you have a Linux distribution, this will more than likely have been done. Otherwise, you will have to create them manually. Do:

$ ls /dev/*st*

and you should have at least the following files:


If you do not, create them (you will have to be root):

$ mknod -m 666 /dev/st0 c 9 0
$ mknod -m 666 /dev/nst0 c 9 128

Note, the above assumes that you are using the first tape on the SCSI bus. If you have two tapes, and you want to use the second one, change the device names to /dev/st1 and /dev/nst1 and create them:

$ mknod -m 666 /dev/st1 c 9 1
$ mknod -m 666 /dev/nst1 c 9 129

If you have a more recent distribution, chances are you will have the MAKEDEV script available in your /dev directory. You can create all the appropriate devices by simply running that script:

$ cd /dev
$ ./MAKEDEV st0
Tape Preparation

Unlike floppy tape drive tapes, SCSI tapes generally do not need formatting. They may, however, need erasing for use under Linux. To erase a tape, do:

$ mt -f /dev/st0 erase

DAT tapes, however, do not need erasing. The easiest way to find out if a particular tape needs erasing is to try using it without erasing first. If you can, well and good; if not, you will have to erase prior to use.

Device Names

Accessing a tape drive is very similar to accessing a file on the hard disk, except that a tape drive has two filenames. For ftape, these two names are generally /dev/ftape and /dev/nftape. If you use zftape, the two device names are generally /dev/qftape and /dev/nqftape. For SCSI, the names are /dev/st0 and /dev/nst0 for the first SCSI tape device, /dev/st1 and /dev/nst1 for the second SCSI tape device, and so on.

When the tape drive is accessed by the first filename (/dev/ftape, /dev/qftape, or /dev/st0), we are said to be accessing the rewinding device. When the tape drive is closed, the tape is automatically rewound to the beginning. When accessing the tape drive via the second filename (/dev/nftape, /dev/nqftape, or /dev/nst0), we are using the non-rewinding device and when the tape drive is closed, the tape is left where it is.

Some applications need to use both devices and you will need to specify the correct names.

Testing Using tar

Now that you have set up your system for a tape drive, you will want to test it. GNU tar is the de facto backup standard under Linux and comes will all distributions. If you do not have it, obtain it from a site near you.

In the examples below, I will use dev_name to indicate your device name. As mentioned above, this will probably be /dev/ftape if you use ftape, /dev/qftape if you use zftape, and /dev/st0 if you use a SCSI drive.

Put a freshly prepared tape into the tape drive and try to make a small backup:

$ tar cf dev_name /etc

This should backup your /etc directory. You can now check to see if the backup was made correctly by:

$ tar df dev_name

Note that if you use ftape, you cannot use the Ar options to tar because of limitations in the current driver. That is, you cannot append files to an archive. You will have to use mt to move the tape to the end of one archive and then create another archive.

A more detailed look at tar is provided in the Tar and Taper for Linux article.

Please note that the above sites are very busy. In the interests of preserving your sanity and minimizing network traffic, find a mirror (and there are many) near you and use that. Both tsx-11 and sunsite will print a list of mirrors if you try to log on when they are busy.

Further Information

The HOW-TOs are an invaluable source of information. There is a HOW-TO for both ftape and for SCSI.

Yusuf Nagree is a part time doctor and a full time Linux hacker (aargh—sorry, full time doctor and part time Linux hacker). He has been a computer buff since his dad bought him a ZX-80 in 1980 and has had various computers over the years. Bored with DOS, OS/2 and Windows, the aspect of Linux he finds most enjoyable is the community spirit and general willingness to help and share knowledge and experience.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.