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

1 comment:

window error 1079 said...

You done a great job for doing tarred up the website's primary directory as well as excluded its images sub-directory.After reading this post it was very pathetic now its sounds look easy.Thanks for sharing.