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.

link|improve this question
feedback

2 Answers

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.

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

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*"
link|improve this answer
+1: Tar can handle symbolic links nicely. The questioner wants to exclude a directory. – MattBianco Mar 23 '11 at 9:52
feedback

Your Answer

 
or
required, but never shown

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