Sunday, February 05, 2012
How to Exclude a Directory for TAR
I am doing a few aesthetic upgrades, so naturally I want to backup some of my website files. However, I do not want everything, i.e. transient files such images. I tarred up the website's primary directory but excluded its images sub-directory.
Frankly speaking, I did not want to waste time and bandwidth downloading images. Here is the syntax to exclude a directory.
# tar cvfp mytarball.tar /mypath/Example.com_DIR --exclude=/mypath/Example.com_DIR/images
Tar everything in the current directory but exclude two files
# tar cvpf mytar.tar * --exclude=index.html --exclude=myimage.png