Armed with a backup strategy in mind, it’s time to select a backup medium. Several types of backup hardware and media are available for use with Fedora Core. Each type has its advantages and disadvantages.
The type of medium to choose depends largely on the amount of data you need to archive, how long you will store backups, how often you expect to recover data from your backups, and how much you can afford to spend. Table 13-1 compares the most common backup media.
High capacity, low cost for archiving massive amounts of data.
Sequential access medium, so recovery of individual files can be slow.
Random access medium, so recovery of individual files is easier. Backups can be restored from any CD-ROM drive.
Limited storage space (up to 700MB per CD).
Random access medium (like CDs). Large capacity (4.7GB, although the actual capacity you can achieve might be less).
DVD-RW drives and DVD-R disks are relatively expensive (though coming down in price). Less common than CD-ROM drives.
Additional hard drive
Allows faster and more frequent backups. Fast recovery from crashes. No media to load. Data can be located and recovered more quickly. You can configure the second disk to be a virtual clone of the first disk, so that you can boot off of the second disk if the first disk crashes.
Data cannot be stored offsite, thus there is risk of data loss if the entire server is destroyed. This method is not well suited to keeping historical archives of the many revisions of your files. The hard drive will eventually fill up. By using removable hard drives, you can overcome this limitation by removing the backup drive when it is full and moving it to a secure location.
The following sections describe how to use magnetic tape, writable DVDs, and writable CDs as backup media. How to use additional hard drives as backup media is described later in this chapter.
Magnetic tape was for years the most common medium used for backing up large amounts of computer data. Tapes provide a low-cost, convenient way to archive your files. Today’s high- capacity tape drives can back up many gigabytes of data on an amazingly small tape, allowing vast amounts of information to be safely stored.
The primary disadvantage of magnetic tape is that it is a sequential access medium. This means that tapes are read or written from beginning to end, and searching for a particular file can be time-consuming. For this reason, tape is a good choice for backing up and restoring entire file systems, but not the ideal choice to recover individual files on a regular basis.
Fedora can use a wide variety of tape drives. Most SCSI tape drives will work with the generic Linux kernel. Even many IDE tape drives are now supported natively, without requiring the drive to operate in a “SCSI emulation” mode. Some drives, however, require installation of additional software.
If your tape drive is attached to an IDE floppy controller cable, you will need to use the ftape driver to access it. Fortunately, the ftape loadable module is bundled with the Linux 2.6 kernel. When your Linux system boots, it should autodetect the tape drive and load the ftape driver. To verify that your system loaded the tape driver, type the following command shortly after you boot your computer:
dmesg | grep ftape
This searches the most recent kernel messages for lines containing the word ftape. If the ftape module was loaded, you should see something like this:
ftape v3.04d 25/11/97  ftape-init.c (ftape_init) - installing QIC-117 floppy tape hardware drive... .  ftape-init.c (ftape_init) - ftape_init @ 0xd08b0060.  ftape-buffer.c (add_one_buffer) - buffer nr #1 @ c1503914, dma area @ c02c0000.  ftape-buffer.c (add_one_buffer) - buffer nr #2 @ c1503c44, dma area @ c0298000.  ftape-buffer.c (add_one_buffer) - buffer nr #3 @ c50abaac, dma area @ c0328000.  ftape-calibr.c (time_inb) - inb() duration: 1109 nsec.  ftape-calibr.c (ftape_calibrate) - TC for `ftape_udelay()' = 310 nsec (at 20479 counts).  ftape-calibr.c (ftape_calibrate) - TC for `fdc_wait()' = 2208 nsec (at 2559 counts).
If the module was not loaded, then you should check whether your kernel is compiled with support for the ftape module and your particular tape drive. It should be available and ready to include as a loadable module.
In most cases, an ftape device can be accessed just like a SCSI device. The primary difference is that an ftape device file contains the letters qft (for QIK Floppy Tape) where a SCSI tape contains st. For example, the device file for the first SCSI tape on your system will probably be /dev/st0; the device file for the first floppy tape will likely be /dev/qft0.
All of the standard tape- and archiving-related programs should work fine with both types of hardware. Nevertheless, there are a few extra programs that you might find useful when working with a floppy tape drive. These programs can be found in the ftape-tools package located at ftp://metalab.unc.edu/pub/Linux/kernel/tapes/. Download the file named ftape-tools-1.09.tar.gz. If a version higher than 1.09 is available, download that instead. Extract the ftape package using the tar command:
$ tar -xzvf ftape-tools-1.09.tar.gz
This extracts the package into an ftape-tools-1.09 directory. Use the cd command to go to that directory and to run the ./configure script to prepare the package’s makefiles. Next, compile the package by typing the make command:
$ ./configure $ make
Finally, assume root privilege using the su command and type make install to install the ftape-tools programs and online man pages to the appropriate directories:
# make install
You should now be ready to test your tape drive. Insert a blank tape into the tape drive and type the following command:
$ mt -f /dev/qft0 rewind
You should hear the tape spin as the system rewinds the tape. This will be a very short process if the tape is already rewound. The mt command provided with ftape-tools is used to scan, rewind, and eject magnetic tapes in a tape drive.
The ftape-tools package also includes a tool for formatting tapes as well. Most tapes now come preformatted. In the event that you have an older floppy controller tape drive that uses unformatted tapes, use the ftformat command to format them:
$ /usr/local/bin/ftformat -f /dev/qft0
Usually, the -f parameter with the device name is the only parameter that you need to supply. Nevertheless, you are encouraged to read the online man page for ftformat to learn more about its options and capabilities.
Another backup medium that is gaining popularity is the writable CD drive. Writable CD drives have several advantages over tape, the primary one being that CDs are a random access medium. This means that the CD drive can quickly locate a particular file on the CD without sequentially scanning through the entire disc. This is useful when you need to keep a revision history of frequently changing data files (such as source code for a software project or drafts of legal documents).
Another advantage is the extremely long life span of CDs. If you want to archive your backups for a very long time, a writable CD drive is a good choice. If your backups are intended for short-term storage, you should probably consider a rewritable or CD-RW CD drive. A rewritable CD (unlike plain writable CDs) can be reformatted and used to store new backups.
The biggest drawback is that a CD can store at most about 700MB of data. In contrast, DVDs can store 4.7GB of data and many tape drives can store multiple gigabytes of data. For example, DAT DDS-3 tapes can hold up to 24GB of compressed data, while 8mm AIT-2 tapes can hold up to 100GB of compressed data.
To write CDs with Fedora Core you need to install the cdrecord package. This package contains components such as the cdrecord, devdump, isodump, isoinfo, isovfy, and readcd commands. The cdrecord package is included with the Fedora Core distribution.
The cdrecord package used to require that you use a SCSI CD drive. If you have an IDE/ATAPI CD drive, you no longer need to configure that drive to do SCSI emulation. In earlier versions of Fedora and Red Hat Linux, however, SCSI emulation is usually enabled automatically.
Because the data written to a CD becomes permanent once it is written, you need to format the CD and copy files to it all in one step. If you formatted it first, you would end up with an empty file system on a CD that can no longer be written to.
The first step is to create an image of the CD file system as a file on your computer. You do this with the mkisofs command. As an example, imagine that you want to back up the home directory for user mary. You would invoke the mkisofs command and pass it the name of the file system image file to create, followed by the directory to base it on:
$ mkisofs -R -o /var/tmp/mary.iso /home/mary
This creates an ISO9660 file system image in a file named mary.iso located in the /var/tmp directory. The -R option causes Linux-specific file ownership and long file names to be used. If your /var partition does not have enough room for the image, choose a different location.
By default, mkisofs preserves the ownership and access rights of files and directories when it creates the file system image. This is appropriate when you are making a backup, but not when you are creating a software distribution CD. In such a case, add the -r option instead of -R as the first parameter to mkisofs. It will then store all files as publicly readable and, where appropriate, executable.
If you have an ATAPI CD drive, you no longer need a SCSI ID for that drive to be able to record to it. You could enter the device name instead of the SCSI ID (such as dev=/dev/cdrom). However, if you have a SCSI CD drive, before you can write the image file to a CD, you must first discover the SCSI bus number, device ID number, and Logical Unit Number (LUN) of the CD drive. You can find out which SCSI device ID the CD drive is using. Invoke the cdrecord command with the single parameter -scanbus:
# cdrecord -scanbus
You should see a response similar to the following:
Cdrecord 2.0 (i686-pc-linux-gnu) Copyright (C) 1995-2002 Jörg Schilling Linux sg driver version: 3.1.25 Using libscg version 'schily-0.7' scsibus0: 0,0,0 0) 'IDE-CD ' 'R/RW 4x4x24 ' '1.04' Removable CD-ROM 0,0,1 1) * 0,0,2 2) * 0,0,3 3) * 0,0,4 4) * 0,0,5 5) * 0,0,6 6) * 0,0,7 7) *
This tells you that the CD drive is using SCSI ID zero. The Logical Unit Number in this case should always be zero, so you now have all three numbers. You supply them to cdrecord as part of the dev parameter.
The SCSI bus number is listed first; it is followed by the ID number, and then by the LUN. The entire command should look similar to this:
# cdrecord -v speed=2 dev=0,0,0 -data /var/tmp/mary.iso
For an ATAPI CD drive, with the CD drive as /dev/cdrom, your command line might appear as follows instead:
# cdrecord -v speed=2 dev=/media/cdrecorder -data /var/tmp/mary.iso
Several additional parameters are included in the command. The -v parameter tells cdrecord to supply verbose output to the screen. The speed parameter tells cdrecord what speed to record at (in this case X2). (You might choose to leave off speed=2 and let cdrecord autodetect the record speed of your CD burner.) The -data parameter tells cdrecord that the next parameter is the name of the file system image to write to the CD. (You can add the -eject parameter to eject the CD when it is done.) As it works, cdrecord should display status messages that look similar to the following:
cdrecord: No write mode specified. cdrecord: Asuming -tao mode. cdrecord: Future versions of cdrecord may have drive dependent defaults. cdrecord: Continuing in 5 seconds... Cdrecord-Clone 2.01a27-dvd (i686-pc-linux-gnu) Copyright (C) 1995-2004 Jörg Schilling TOC Type: 1 = CD-ROM scsidev: '/dev/cdrom' devname: '/dev/cdrom' scsibus: -2 target: -2 lun: -2 Warning: Open by 'devname' is unintentional and not supported. Linux sg driver version: 3.5.27 Using libscg version 'schily-0.8'. cdrecord: Warning: using inofficial libscg transport code version (schily - Red Hat-scsi-linux-sg.c-1.80-RH '@(#)scsi-linux-sg.c 1.80 04/03/08 Copyright 1997 J. Schilling'). SCSI buffer size: 64512 atapi: 1 Device type : Removable CD-ROM Version : 0 Response Format: 1 Vendor_info : 'IDE-CD ' Identifikation : 'R/RW 4x4x24 ' Revision : '1.04' Device seems to be: Generic mmc CD-RW. Using generic SCSI-3/mmc CD-R/CD-RW driver (mmc_cdr). Driver flags : MMC SWABAUDIO Supported modes: TAO PACKET RAW/R16 Drive buf size : 1572864 = 1536 KB FIFO size : 4194304 = 4096 KB Track 01: data 0 MB Total size: 0 MB (00:04.02) = 302 sectors Lout start: 1 MB (00:06/02) = 302 sectors Current Secsize: 2048 ATIP info from disk: Indicated writing power: 5 Is not unrestricted Is not erasable Disk sub type: Medium Type B, low Beta category (B-) (4) ATIP start of lead in: -12369 (97:17/06) ATIP start of lead out: 359849 (79:59/74) Disk type: Short strategy type (Phthalocyanine or similar) Manuf. index: 69 Manufacturer: Moser Baer India Limited Manufacturer is guessed because of the orange forum embargo. The orange forum likes to get money for recent information. The information for this media may not be correct. Blocks total: 359849 Blocks current: 359849 Blocks remaining: 359547 Starting to write CD/DVD at speed 4 in real TAO mode for single session. Last chance to quit, starting real write 0 seconds. Operation starts. Waiting for reader process to fill input buffer ... input buffer ready. trackno=0 Performing OPC... Starting new track at sector: 0 Track 01: 322 of 322 MB written (fifo 100%) [buf 99%] 2.0x. Track 01: Total bytes read/written: 338395136/338395136 (165232 sectors). Writing time: 1110.710s Average write speed 2.0x. Fixating... Fixating time: 126.108s cdrecord: fifo had 5331 puts and 5331 gets. cdrecord: fifo was 0 times empty and 5262 times full, min fill was 96%.
After cdrecord finishes writing the CD and your shell prompt returns, delete the file system image file /var/tmp/mary.iso. Label the CD appropriately and store it in a safe place.
If you need any files that were copied to the CD, just return the CD to the CD drive. If it doesn’t automatically open a window displaying the contents of the CD, type: mount/media/cdrecorder. Open /media/cdrecorder in a folder window and copy the files you want.
See Chapter 8 for more information on cdrecord. You can also learn more about installing and troubleshooting writable CD drives from the CD-Writing-HOWTO. If you are using a desktop Fedora system, you might want to use a graphical CD writer instead. Chapter 8 also describes the K3B graphical tool for copying and burning CDs and DVDs.
Using a writable DVD drive and the dvdrecord command, you can back up your data to DVD-R disks. The procedure is almost identical to backing up data onto a CD disk, with the following exceptions:
You use the dvdrecord command instead of cdrecord (although they both have nearly identical interfaces).
Each backup disk can hold a lot more data (4.7GB compared to 700MB).
Both the DVD writer and medium are more expensive than the CD counterparts.
When manufacturers say 4.7GB, they are talking about 1000MB per GB, not 1024MB. Therefore, you can really only store up to about 4.4GB of data on a DVD.
The dvdrecord command should allow you to burn DVDs on any DVD burner that is compliant with the Multimedia Command (MMC) standard. Development of the dvdrecord command was done on a Pioneer DVR-A03 DVD writer.
Follow the procedure in the “Writable CD drives” section to create a file system image file (using mkisofs) and determine the location of your DVD-R driver. Then use the dvdrecord command to actually burn the DVD. Here is an example of a dvdrecord command line that burns a file system image called bigimage.cd:
# dvdrecord -v speed=2 dev=/dev/cdrom -data bigimage.cd
A tool that can be useful for mastering DVDs is the growisofs command. That command combines the functionality of mkisofs (for creating a file system image) and CD recording software (for writing that image to a CD).