Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to make a cronjob who makes a tag.gz of everything inside a directory in a recursive way. BUT there is a HUGE directory full of jpg's. I don't want this one in the backup.
Additional points if it can backup symbolic links.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Simple - you use tar's --exclude flag:

$ tar -zcvf mybackup.tar.gz --exclude '*.[Jj][Pp][Jj]' StuffToBackup

That will exclude *.jpg, *.jpG, *.jPg, *.jPG, *.Jpg, *.JpG, *.JPg and *.JPG

You can specify multiple --exclude flags if you want to exclude more things.

share|improve this answer
    
I didn't know about the [] trick NICE! –  The Disintegrator Mar 24 '11 at 20:40

You could use the exclude pattern option of tar in the following way:

Assuming you want to backup a dir called foo and exclude foo/bar, you would do:

tar cvf backup.tar foo/ --exclude="foo/bar*"
share|improve this answer
    
+1: Tar can handle symbolic links nicely. The questioner wants to exclude a directory. –  MattBianco Mar 23 '11 at 9:52

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.