Online Book Reader

Home Category

UNIX System Administration Handbook - Evi Nemeth [119]

By Root 3000 0
Like tar, cpio can be used to move directory trees. The command

find fromdir -depth -print | cpio -pdm todir

would make a copy of the directory tree fromdir in todir. Most versions of cpio do not allow multiple tape volumes. Some versions of cpio do not handle pipes gracefully, and only the superuser can copy special files. When using cpio, read your man pages carefully; the options vary greatly among systems.

dd: twiddle bits


dd is a file copying and conversion program. Unless it is told to do some sort of conversion, dd just copies from its input file to its output file. If a user brings you a tape that was written on some non-UNIX system, dd may be the only way to read it.

One historical use for dd was to create a copy of an entire filesystem. However, a better option these days is to newfs the destination filesystem and then run dump piped to restore. dd can sometimes clobber partitioning information if used incorrectly. It can only copy filesystems between partitions of exactly the same size.

dd can also be used to make a copy of a magnetic tape. With two tape drives, say, /dev/rmt8 and /dev/rmt9, you’d use the command

% dd if=/dev/rmt8 of=/dev/rmt9 cbs=16b

With one drive (/dev/rmt8), you’d use the following sequence:

% dd if=/dev/rmt8 of=tfile cbs=16b

/* Change tapes. */

% dd if=tfile of=/dev/rmt8 cbs=16b

% rm tfile

Of course, if you have only one tape drive, you must have enough disk space to store an image of the entire tape.

Another historical use of dd was to convert between various flavors of QIC tape that differed only in their byte order. For example, to read on a Sun machine a tar tape written on an SGI machine, you could use

% dd if=/dev/rst8 conv=swab | tar xf -

The name of the tape device is system dependent.

volcopy: duplicate filesystems


volcopy makes an exact copy of a filesystem on another device, changing the block size as appropriate. It is available on Solaris, HP-UX, and Linux systems. You can use volcopy to back up a filesystem to a removable disk pack or to make a complete copy of a filesystem on tape. Consult the man page on your system for the appropriate options and syntax.

10.7 USING MULTIPLE FILES ON A SINGLE TAPE


In reality, a magnetic tape contains one long string of data. However, it’s often useful to store more than one “thing” on a tape, so tape drives and their UNIX drivers conspire to provide you with a bit more structure. When dump or some other command writes a stream of bytes out to a tape device and then closes the device file, an “end of file” marker is automatically placed on the tape. This marker separates the stream from other streams that are written subsequently. When the stream is read back in, reading stops automatically at the EOF.

You can use the mt command to position a tape at a particular stream or “file set,” as mt calls them. mt is especially useful if you put multiple files (for example, multiple dumps) on a single tape. It also has some of the most interesting error messages of any UNIX utility. The basic format of the command is

mt [-f tapename] command [count]

tapename is the device name of the tape (nonrewinding if you want to do any sort of file operations). HP-UX uses -t instead of -f.

There are numerous choices for command. They vary from platform to platform, so we discuss only the ones that are essential for doing backups and restores:

rew

rewinds the tape to the beginning.

offl

puts the tape off-line. On some tape drives, this command causes the tape to pop out of the drive. Most dump scripts use this command to eject the tape when they are done, giving a clear indication that everything finished correctly.

status

prints information about the current state of the tape drive (whether a tape is loaded, etc.).

fsf [count]

fast-forwards the tape. If no count is given, fsf skips forward one file. With a numeric argument, it skips the specified number of files. Use this command to skip forward to the correct filesystem on a tape with multiple dumps.

bsf [count]

should backspace

Return Main Page Previous Page Next Page

®Online Book Reader