Excluding files or folders with tar is straightforward once you know the --exclude option.
Assume a directory tree like this:
| |
If you want to archive the directory but leave out file2 and the nested folder/, you can do:
| |
That is a handy pattern when creating backups and you want to skip generated files, caches, or other directories you do not need in the archive.