Skip to main content

Posts

Showing posts with the label Linux

How to create tar by excluding directories in centos Linux

I had a problem to compress files in my webserver. Because my images and backup folders were too large. Then I thought to exclude those directories and create a tar file. I have used --exclude option which matches patterns. First I have used following command to exclude images and backup folder. tar -cvf "new_tar_cha_2013-11-26.tar.gz" .  --exclude "path/to/backup/backup/*" --exclude "images/*" > error_tar_cha.log It excluded backup folder correctly. But It excluded all the images folders inside my directory. Because it matches the pattern . My solution was, I renamed to root images folder to different name - "images-cha1" and excluded it. It fixed my problem. tar -cvf "new_tar_cha_2013-11-26.tar.gz" .  --exclude "path/to/backup/backup/*" --exclude "images-cha1/*" > error_tar_cha.log I think this will be helpful for others also. Thanks