O'Reilly logo

Essential System Administration, 3rd Edition by Æleen Frisch

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required