Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Absolute BSD - The Ultimate Guide To FreeBSD (2002).pdf
Скачиваний:
29
Добавлен:
17.08.2013
Размер:
8.15 Mб
Скачать

[1]Some sysadmins will disagree and insist that tar(1) is better. This is a disagreement of epic proportions in the UNIX community, and any recommendation I make will undoubtedly anger the 49 percent of the sysadmin community that is devoted to the other tool. (The remaining 2 percent insists that the only way to provide proper backups is via one of a dozen other tools.)

Restoring from an Archive

Archives are nice, but they're useless unless you can use them to recover your system. Dump's recovery utility, restore(8), can recover either complete filesystems or individual files. As with tar and dump, the −f flag lets you choose the device or file you wish to restore from.

Checking the Contents of an Archive

To list the contents of an archive, use the −t flag. If you add a filename after −t, restore will check to see if that file exists, like so:

...............................................................................................

# restore −f /dev/ast0 −t /etc/motd

Dump date: Thu Mar 22 13:30:39 2001 Dumped from: the epoch

Level 0 dump of / on turtledawn.blackhelicopters.org:/dev/ad0s2a

Label: none

 

18935

./etc/motd

#

 

...............................................................................................

In this example, we're using the tape drive device node of /dev/ast0 in the input, which, as we discussed in the "Device Nodes" section of this chapter, is an IDE drive. Using this device node tells the command to rewind the tape when it finishes. The −t tells restore to check for the file /etc/motd. Restore tells us when the dump took place, which system it was taken on, and which disk device was backed up.

Extracting Data from an Archive

Once you know whether a file is in an archive, you can extract data from the archive in two ways: on a file−by−file basis or as a complete filesystem.

Restoring a File

If all you want is a few select pieces, use −x and the filename to extract only the named file. For example, to recover /etc/namedb from a dump archive written to a file, you'd enter the following command and see the subsequent response :

...............................................................................................

# restore −f /var/tmp/slashbackup −x /etc/namedb

You have not read any tapes yet.

Unless you know which volume your file(s) are on you should start with the last volume and work towards the first.

Specify next volume #: Specify next volume #: 1

set owner/mode for '.'? [yn] y

#

...............................................................................................

58

Note Notice that restore asks you for a volume number. If you're recovering from a file, this is irrelevant, but if you're restoring from a series of tapes, you'll need to enter the tape number. If you only have one tape, enter 1.

Once the preceding command completes, the current directory should have a directory etc, containing the complete namedb directory.

Restoring a Filesystem

Restoring an entire filesystem is rather straightforward; just bear in mind that it's best not to restore a filesystem over the existing one. If you need massive restorations, it's safer to erase the partition and start over.

In the following example, we will completely erase a partition on a second IDE disk and recover from our backup tape. We won't go into details on the disk work here (see Chapter 13 for more information), but what we're doing can be summarized like this:

1.We build a new filesystem with fdisk.

2.We attach that filesystem to the directory system, under/mnt.

3.We go into that directory and run the restore from the tape device/dev/ast0.

These are the commands:

...............................................................................................

#newfs /dev/ad1s1g

#mount /dev/ad1s1g /mnt

#cd /mnt

#restore −rf /dev/ast0

...............................................................................................

Restoring Interactively

One of dump's most interesting features is interactive mode, −i, which you can use to crack open a dump (either file or tape) and access it with a commandline tool, marking files that you want to restore. Interactive mode is terribly useful when a user says something like, "I accidentally erased my resume. It's somewhere in my home directory, and the name has the word resume in it—I'm not sure exactly what it's called. Can you get it back?" Obviously the −t flag won't help us; we don't know exactly what the file is called! Instead, we can wander around in restore's interactive mode until we find the file.

The following listing shows me interactively opening a dump file called root.dump. (It works just as well on a dump on tape, mind you!) Restore then presents a restore command prompt, which looks a lot like your regular FreeBSD command prompt but only supports commands specific to restore.

...............................................................................................

#restore −i −f root.dump

59