Exclude files using multiple patterns
tar -czf backup.tar.gz --exclude=PATTERN1 --exclude=PATTERN2 ... /path/to/backup
Exclude files using an exclude file filled with a list of patterns
tar -czf backup.tar.gz -X /path/to/exclude.txt /path/to/backup
Exclude files using tags by placing a tag file in any directory that should be skipped
tar -czf backup.tar.gz --exclude-tag-all=exclude.tag /path/to/backup
Use a wild card in the --exclude
option argument.
For example, suppose you have 3 directories a, b & c.
Each directory has 3 files.
- a: d e f
- b: g h i
- c: j k l
To exclude all of the files in b, use --exclude 'b/*'
To also exclude the directory b, use --exclude 'b/*' --exclude 'b'