Опубликован: 06.08.2012 | Уровень: специалист | Доступ: платный
Лекция 14:

Tapes, backups and floppy disks

< Лекция 13 || Лекция 14: 123 || Лекция 15 >
Аннотация: Backing up your data; Using floppy disks under FreeBSD.

In "Chapter 11" we looked at hard disks. In this chapter, we'll consider how to guard against data loss, and how to transfer data from one location to another. These are functions that UNIX traditionally performs with tapes, and we'll look at them in the next sections. Because FreeBSD runs on PCs, however, you can't completely escape floppy disks, though it would be an excellent idea. We'll look at floppies on page 256.

Backing up your data

No matter how reliable your system, you are never completely protected against loss of data. The most common reasons are hardware failure and human error. By comparison, it's very seldom that a software error causes data loss, but this, too, can happen.

UNIX talks about archives, which are copies of disk data in a form suitable for writing on a serial medium such as tape. You can, however, write them to disk files a well, and that's what people do when they want to move a source tree from one system to another. You'll also hear the term tarball for an archive made by the tar program, which we discuss below.

What backup medium?

Traditionally, PCs use floppy disks as a removable storage medium. We'll look at floppies below, but you can sum the section up in one statement: don't use floppy disks.

Floppy disks are particularly unsuited as a backup medium for modern computers. Consider even a minimal system with a 2 GB hard disk. Storing 2 GB of data on floppies requires about 1,500 floppies, which, at $0.30 each, would cost you $450. Copying the data to a floppy takes about 50 seconds per floppy, so the raw backup time would be about 21 hours, plus the time it takes you to change the floppies, which could easily take another three or more hours. During this time you have to sit by the computer playing disk jockey, a total of three days' work during which you could hardly do anything else. When you try to read in the data again, there's a virtual certainty that one of the floppies has a data error, especially if you read them with a different drive.

By contrast, a single DDS or Exabyte cassette stores several gigabytes and costs about $6. The backup time for 2 GB is about 90 minutes, and the operation can be performed completely unattended.

A number of cheaper tape drives are also available, such as Travan tapes. FreeBSD supports them, but for one reason or another, they are not popular. FreeBSD once used to have support for "floppy tape ", run off a floppy controller, but these tapes were very unreliable, and they are no longer supported.

You can also use writeable "CD-ROMs" (CD-Rs) for backup purposes. By modern standards, the media are small (up to 700 MB), but they have the advantage of being readily accessible on other systems. We looked at CD-Rs in "Chapter 13" .

Tape devices

FreeBSD tape devices have names like /dev/nsa0 (see page 196). Each letter has a significance:

  • n means non-rewinding . When the process that accesses the tape closes it, the tape remains at the same position. This is inconvenient if you want to remove the tape (before which you should rewind it), but it's the only way if you want to handle multiple archives on the tape. The name of the corresponding rewind device has no n (for example, the rewind device corresponding to /dev/nsa0 is /dev/sa0). A rewind device rewinds the tape when it is closed.
    Older releases of FreeBSD used the names /dev/nrsa0 and /dev/rsa0. r stands for raw, in other words a character device. Since the removal of block devices, this letter is superfluous, but you might see it occasionally in older documents.
  • sa stands for serial access, and is always SCSI. You can also get ATAPI tape drives, which are called /dev/ast0 and /dev/nast0, and the older QIC-02 interface tapes are called /dev/wst0 and /dev/nwst0.
  • 0 is the unit number. If you have more than one tape, the next will be called /dev/nsa1, and so on.

Backup software

FreeBSD does not require special "backup software." The base operating system supplies all the programs you need. The tape driver is part of the kernel, and the system includes a number of backup programs. The most popular are:

  • tar, the tape archiver, has been around longer than anybody can remember. It is particularly useful for data exchange, since everybody has it. There are even versions of tar for Microsoft platforms. It's also an adequate backup program.
  • cpio is an alternative backup program. About its only advantage over tar is that it can read cpio format archives.
  • pax is another alternative backup program. It has the advantage that it can also read and write tar and cpio archives.
  • dump is geared more towards backups than towards archiving. It can maintain multiple levels of backup, each of which backs up only those files that have changed since the last backup of the next higher (numerically lower) level. It is less suited towards data exchange because its formats are very specific to BSD. Even older releases of FreeBSD cannot read dumps created under FreeBSD Release 5.
  • amanda , in the Ports Collection, is another popular backup program.

Backup strategies are frequently the subject of religious wars. I personally find that tar does everything I want, but you'll find plenty of people who recommend dump or amanda instead. In the following section, we'll look at the basics of using tar. See the man page dump(8) for more information on dump.

tar

tar, the tape archiver, performs the following functions:

  • Creating an archive, which can be a serial device such as a tape, or a disk file, from the contents of a number of directories.
  • Extracting files from an archive.
  • Listing the contents of an archive.

tar does not compress the data. The resulting archive is slightly larger than the sum of the files that it contains, since it also contains a certain amount of header information. You can, however, use the gzip program to compress a tar archive, and tar invokes it for you automatically with the -z option. The size of the resultant archives depends strongly on the data you put in them. JPEG images, for example, hardly compress at all, while text compresses quite well and can be as much as 90% smaller than the original file.

< Лекция 13 || Лекция 14: 123 || Лекция 15 >
Бехзод Сайфуллаев
Бехзод Сайфуллаев
Узбекистан, Бухара, Бухарский институт высоких технологий, 2013
Василь Остапенко
Василь Остапенко
Россия