Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Linux+ Certification Bible.pdf
Скачиваний:
46
Добавлен:
15.03.2015
Размер:
3.78 Mб
Скачать

464 Part V Maintaining the Linux System

backup first, and then restore any necessary incremental or differential backups after that. If you restore your full backup after the incremental or differential backups, it may overwrite any newer versions of the files that you just restored.

Always test your restore procedure. Companies spend much time and money formalizing a backup process without ever properly testing restores. Testing a backup is pointless unless you also test a restore from that backup. Problems with the backup device or media may render the backup useless, even if it appears that the backup process worked.

Offsite storage

Offsite storage involves transporting your most current backup media to a safe, offsite location. A reputable records management company can perform this service for you; many of these companies specialize in the storage of magnetic backup media. Offsite storage of your backup media will protect your valuable data in the event of a physical disaster at your current site. Only the system administrator and key management personnel who might need access to the data should have security access to retrieve and send tapes offsite.

Realistically, you should send your most recent full backup of all systems and any archived data to your offsite location. Make two copies of your full backups — one to keep onsite for availability of restores, and one to keep offsite for protection from disaster.

Don’t send your only copy of a full backup offsite. If the tapes are lost in transit or at the offsite storage facility, you have nothing to fall back on. This is rare, but it can happen, so protect yourself by making duplicate copies.

Linux Backup Tools and Commands

5.10 Perform and verify backups and restores

To back up your system, you can utilize several tools and commands to perform the necessary tasks.

Third party tools

The best way to properly back up your system is to use third-party software to schedule backups and perform restores. These types of specialized software make the process of scheduling and performing backups much simpler than using basic command line tools. They also ease tape administration by allowing you to assign tape and volume labels, and support bar-coded labels as well.

Chapter 15 Backing Up Your Linux System 465

A simple point-and-click interface simplifies the process of file restoration because you can search down your directory trees and tape histories to find the exact file that you need. Third party backup programs also offer extensive reporting and management features that let you easily customize reports from backup logs in order to focus on the information that you need the most.

If you are performing simple file system dumps, you probably don’t need extensive backup software. If you are in an enterprise environment, however, you may need to back up several different systems, such as Linux, Unix, NT, and Netware, and third party tools give you a central, common interface to do so. The disadvantage of using third party tools is that they usually back up files by using a proprietary database. If you try to restore files by using a different program or command line tool, it may not work.

If you change the program that you use to back up files, you should retain the older version for at least one year — just in case a restore is needed of a file that was backed up by using the older system.

Most third party solutions also come with modules for specialized backup needs, such as databases or mail servers, which need different backup configurations than regular user files. Modules are also available to take care of open files during a backup. For example, if some users have left their computers on with files still open, the backup system can’t back them up. These specialized modules allow the files to be backed up, even if they are open.

The following are some of the most popular programs available for backing up Linux systems:

Arcserve for Linux: www.ca.com/arcserve/arcserve_linux.htm

Legato NetWorker for Linux: www.legato.com/products/protection/ networker

Veritas NetBackup for Linux: www.veritas.com/us/products/netbackup

Merlin PerfectBackUP+: www.merlinsoftech.com/products/backup.htm

Tape devices

In order to back up data, you need a device to send the data to, which can be another disk, a floppy, or a tape drive. Copying to another disk is a simple matter because you only need to refer to it by its pathname, such as /mnt/backup.

For other devices, such as tape and floppy, all devices in Linux are defined in the /dev directory. For example, the first SCSI tape drive is referred to as /dev/st0. The device name /dev/nst0 means that the tape is non-rewinding, so for each backup, it won’t overwrite the previous session. Table 15-1 shows an example of the device names that may be used for tape backup.

466 Part V Maintaining the Linux System

 

Table 15-1

Linux Backup Devices

 

 

Device

Device Name

 

 

First SCSI Tape Drive

/dev/st0

 

 

First “No-Rewind” SCSI Tape Drive

/dev/nst0

 

 

Second SCSI Tape Drive

/dev/st1

 

 

First ATAPI Tape Drive

/dev/ht0

 

 

First “No-Rewind” ATAPI Tape Drive

/dev/nht0

 

 

Second ATAPI Tape Drive

/dev/ht1

 

 

Floppy Drive

/dev/fd0

 

 

Commands

The following command examples utilize a default device of /dev/tape to avoid confusion.

Tape device commands

The tape device must be mounted before it can be used by any other backup command or tool. Technically, you are not mounting the tape drive as a file system; rather, you are using the mount command to direct the tape drive to fast-forward or rewind the tape to the proper position. The following commands work on the first tape device, but if you need to specify the device, use the -f option (for example,

mt -f /dev/tape status).

mt status: Tells status of tape drive

mt fsf 2: Fast-forwards the specified number of files on the tape

mt asf 2: Fast-forwards to the specified file number

mt rewind: Rewinds the tape to the beginning

tar

The tar command, short for tape archive, is one of the oldest Unix commands for creating archive files for storage on magnetic tape. The tar command isn’t limited for use on tape devices; it is commonly used to create any type of file archive and to save it to any type of device.

The tar command does not compress data; it only creates file archives. For backup use, you should use the hardware compression that’s built into your storage unit. If you want to compress files with tar, you can use it in conjunction with the compress or gzip commands.

Chapter 15 Backing Up Your Linux System 467

The format of the tar command is:

tar [options] (file1) (file2) ...

You can use several options and arguments with the tar command:

c: Tells tar to create a new archive file

v: Verbose mode; this will print each filename as it is archived

f: Lets you specify a filename for the archive

x: Tells tar to extract files from an archive

p: Tells tar to keep permissions on files when extracted from an archive

To back up the entire /home directory to a tape device, use the following command:

tar -cvf /dev/tape /home

To extract the same file into the current directory, use the following command:

tar -xvfp /dev/tape

To see the contents of a tar archive on tape, use the following command:

tar -tvf /dev/tape

To restore a single file from tape, use the following command:

tar -xvfp /dev/tape /home/file

Know how to create and extract from a tar archive file on tape.

cpio

The cpio command, which means “copy in, copy out,” is similar to the tar command in that it is used for copying files in and out of archives, including tar and its own binary format. The cpio command has three operating modes:

Copy-in mode: cpio copies files out of an archive or lists the archive contents. Only files in the archive whose names match one or more of those patterns are copied from the archive. If no patterns are given, all files are extracted.

Copy-out mode: cpio copies files into an archive. It reads a list of filenames, one per line, on the standard input and writes the archive onto the standard output. Typically, use the find command to generate the list of filenames.

Copy-pass mode: cpio copies files from one directory tree to another, combining the copy-out and copy-in steps without actually using an archive. It reads the list of files to copy from the standard input. The directory into which it will copy them is given as a non-option argument.

468 Part V Maintaining the Linux System

These are some command options that are often used when using the cpio command:

i: Copy-in mode, extract

o: Copy-out mode, create

t: Lists the contents of the input

p: Copy-pass mode

d: Create directories as required

To use the cpio command to list the contents of the archive, use the following command:

cpio -it < [archivefile]

To extract files from an archive, such as an entire /home directory, use the following command:

cpio -id “/home” < [archivefile]

Most often, the cpio command is used in conjunction with the find command to more precisely find the files that are needed in an archive:

find /home -print | cpio -p /dev/tape

dump and restore

Use the dump command to dump entire Linux file systems to the output device of your choice, which can be a disk file or a tape device.

Here are some of the command options that can be used with the dump command:

[0-9]: This option sets the dump level for the current operation. A dump level of 0 indicates a full backup. Any level higher than 0 indicates an incremental backup, so dump copies all new or modified files since the last dump of the same or lower level.

f: This option indicates the file or device that the command is writing to.

To dump the entire /home partition to a tape device, use the following command:

dump -f /dev/tape -0 /home

Use the restore command to restore files that were backed up by using the dump command. The dump command saves the directory structure of the files that were backed up, so when you invoke the restore command, you can navigate up and down the directory tree to choose the files to restore.

Соседние файлы в предмете Операционные системы