Shell command to tar directory excluding certain files/folders

You can have multiple exclude options for tar so

$ tar --exclude="./folder" --exclude="./upload/folder2" -zcvf /backup/filename.tgz .

etc will work. Make sure to put --exclude before the source and destination items.

Leave a Comment