Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

T would like to use the tar command in Linux to back up some files, but i would like to exclude a specific directory from the archive.

How can I do that?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

so, lets back up the directory /directory and everything in it, but ignoring any files called IGNORE-ME.

tar -cf backup.tar /directory --exclude "IGNORE-ME"

If it wasn't snowing out, i'd probably point out that man tar is as good as RTFM (and google 'tar exclude file' is even faster).

share|improve this answer

You can also put all of the patterns in a file and use:

-X, --exclude-from=FILE
              exclude files matching patterns listed in FILE
share|improve this answer
    
much better answer than mine -well, far more practical assuming you want to mask more than the one file :) see, I read the man page, but obviously not all the way down to -X ;) –  BuildTheRobots Jan 6 '10 at 20:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.