tar exclude directory
--excludeflag should be placed before the source directory.
Some Linux distributions allow
--exclude /path/to/excluded/, while others require
All distributions I have used allow the
Other flags like
-czfshould be added directly after the
tarcommand, such as
The exclusion directory doesn't have the trailing backslash like
Here's the Example for excluding the
uploads folder in a WordPress installation.
tar -czf backup.tgz --exclude="/var/www/wordpress/wp-content/uploads" /var/www/wordpress/wp-content/
- You can use the above code to exclude files or directories from your archive.
- You can use globbing patterns in the exclude flag. For example,