Sunday, May 27, 2007

Exclude Files or Directories from an Archive using tar

Sometimes you might want to routinely backup certain files or directories that are on a mass storage device (RAID), but you don't want to backup the entire RAID. You can do this by using the tar command's exclude option. You probably want to exclude the exclude and tarball files. Here's an example of its use.

First I create the exclude file and give it an arbitrary name, filesDir_to_exclude

#cat > filesDir_to_exclude
filesDir_to_exclude
esofthub.tar
temp1
temp2
temp2
junk
large_directory
larger_directory
massive_archive_directory
...
Control d

#cd /raid
#tar cvfpX esofthub.tar filesDir_to_exclude *

No comments: