11.5 Making Table of Contents Files


It is often convenient to have online listings of the contents of system backup tapes. For one thing, they make it much easier to figure out which tape has the file you need to restore, especially when multiple levels of incremental backups are in use. It is quite easy to create such files at the time the backup is performed.

If you're using tar or cpio for backup, you can take advantage of the -v option to create a listing of the tape's contents as it is written, as in these examples:

$ today='date +%d%b%Y'  $ tar -cv /home > /backup/home_full_$today.TOC                                           or $ tar -cv /home | tee /backup/home_full_$today.TOC

Both tar commands archive the contents of /home, generating a long, directory-like listing as it does so and saving it to a file with a name like /backup/home_full_21mar1995.TOC. The second command also displays the same output on the screen.

cpio sends the file list to standard error, so it must be captured slightly differently:

$ toc='date +/backup/home_full_%d%b%y.TOC'  $ find /home -print |  cpio -ov > /dev/rmt0 2> $toc

If you want to use the C shell, the commands are a little different:

% set toc='date +/backup/home_full_%d%b%y.TOC'  % (find /home -print | cpio -ov > /dev/rmt0) >& $toc

The file lists produced by cpio commands like these contain only the pathnames of the files in the archive. If you want a more detailed listing, you can generate it with a second cpio command or a more complex pipe leading up to the cpio backup command:

$ cpio -itv < /dev/rmt0 > $toc  $ find /home | cpio -o | tee /dev/rmt0 | cpio -t -i -v > $toc

The first command lists the files in the archive on tape. The second command avoids having to reread the backup tape by using the find command to generate a list of files, which cpio makes into an archive. This archive is then sent both the the tape drive and to another cpio command. The latter lists the archive contents and writes it to the specified table-of-contents file.

Making a table of contents file for a dump tape requires a subsequent restore command. For example, here is a script that performs a backup with dump and then creates a table-of-contents file with restore:

#!/bin/csh # bkup+toc - perform dump and verify tape/make TOC file # $1 = filesystem # $2 = dump level (default=0) #  if ($#argv < 1) then    echo "do_backup: filesystem [dump-level]"   exit 1  endif set lev=0  if ("$2" != "") set lev=$2  dump -${lev} -u -f /dev/rmt1 $1  if ($status) then    echo "do_backup: dump failed"   exit 1  endif  restore -t -v -f /dev/rmt1 > /backup/`date +$1:t_%m-%d-%Y.$lev`

This script runs the dump command on the filesystem given as its first argument, using the backup level specified as its second argument (or level 0 by default). If the dump command exits normally, the restore command is used to verify the backup and write its contents to a file. The file's name contains the disk name and the month, day, and year when the backup was done, and its extension is the backup level: e.g., chem_06-24-2001.2 would be the filename for a level 2 backup of /chem made on June 24, 2001.

On an HP-UX system, you can use this frecover command to crea te a table-of-content file:

# frecover -r -Nv -f /dev/rmt/0m > $toc


Essential System Administration
Essential System Administration, Third Edition
ISBN: 0596003439
EAN: 2147483647
Year: 2002
Pages: 162

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net