amuck-landowner

How do you exclude a sub-directory via bash?

MannDude

Just a dude
vpsBoard Founder
Moderator
For example, say you want to create an archive of a directory to back it up:

tar -zcf /some/backup/folder/yoursite_www_$(date +"%m_%d-%Y_%H:%M").tar.gz /home/someuser/somesite/public_htmlSo that'll create an an archive of everything located in /home/someuser/somesite/public_html. Great. But what if you have a folder with large files in it that you want to exclude from being backed up? For example: /home/someuser/somesite/public_html/bigfiles ? How would you exclude that from being archived?
 

perennate

New Member
Verified Provider
Good answer: man tar

(or, if you're looking for a replacement for bash wildcard matching that supports exclusion, use find)

Bad answer:

Code:
tar -zcf /some/backup/folder/yoursite_www_$(date +"%m_%d-%Y_%H:%M").tar.gz --exclude=bigfiles /home/someuser/somesite/public_html
 
Last edited by a moderator:
Top
amuck-landowner