tar ):

# tar -cf /dev/st0 /system-* /etc /home

tar: Removing leading Q/' from member names

tar: Removing leading Q/' from hard link targets

In this command, /dev/st0 is the first tape drive, and /etc and /home are the directories being backed up.

To perform a compressed backup, add the z (for gzip compression) or j (for bzip2 compression) option:

# tar -czf /dev/st0 /system-* /etc /home

tar: Removing leading Q/' from member names

tar: Removing leading Q/' from hard link targets

Here is a script that will perform a tape backup:

#!/bin/bash

#

# backup-tape :: backup selected directories to a compressed tape

#

# List of the directories to be backed up

DIRLIST='

/etc /home '

# Create timestamp file

(

rm -f /system-*

touch /system-$(hostname)

# Produce the tape

tar -czf /dev/st0 /system-* $DIRLIST

# Eject the tape if possible

mt -f /dev/st0 eject

) 2>&1|mail -s 'Backup Log $(hostname)' backup-alert

Save this script as /usr/local/bin/backup-tape .

Like the backup-dvd script, this script will send an email report to the email alias backup-alert . To include a list of files in the email report, add the -v option to the tar command:

tar -cz v f /dev/st0 /system-* $DIRLIST

To produce a backup tape, run the script from the command line:

# backup-tape

It's best to run this script automatically every night (see Lab 6.4, 'Scheduling Tasks ').

6.3.1.11. Restoring files from backups

When restoring from tape, it's a good idea to restore to a location other than the original file location to ensure that critical data is not accidentally overwritten. These commands will perform a full restore of a tape to the directory /tmp/restore :

# mkdir /tmp/restore

# cd /tmp/restore

# tar xvzf /dev/st0

To restore only certain files, specify the filenames as arguments to tar :

# tar xvzf /dev/st0 home/chris/

If the file specified is a directory, all of the files and subdirectories in that directory will be restored.

Restoring from disc is easy: just copy the files that you want to the location that you want. You can do this graphically, or you can restore all of the files on the disc:

# mkdir /tmp/restore

# cd /tmp/restore

# cp -r /media/CDROM/* .

6.3.1.12. Viewing the table of contents and verifying a backup

To verify that a tape backup is readable, use tar's t option to view a table of contents of the tape:

# tar tvzf /dev/st0

-rw-r--r-- root/root 0 2006-07-01 01:34:24 system-bluesky.fedorabook.com

drwxr-xr-x root/root 0 2005-09-23 15:01:38 etc/gconf/

drwxr-xr-x root/root 0 2005-03-02 11:59:15 etc/gconf/gconf.xml.mandatory/

drwxr-xr-x root/root 0 2005-08-29 00:53:34 etc/gconf/1/

-rw-r--r-- root/root 840 2005-03-02 11:59:11 etc/gconf/1/path

drwxr-xr-x root/root 0 2006-03-20 01:33:22 etc/gconf/schemas/

...(Lines skipped)...

Since the label file /system-* is the first file on the tape, you can view the originating machine as well as the date and time of the backup by just viewing the first line of the table of contents:

# tar tvzf /dev/st0|head -1

-rw-r--r-- root/root 0 2006-07-01 01:34:24 system-bluesky.fedorabook.com

To verify that all of the files on an optical disc are readable, use find to read each file on the mounted disc:

# find /media/cdrecorder -exec cp {} /dev/null ;

Only errors will be reported.

Вы читаете Fedora Linux
Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату