Excluding Directories While Using TAR Command

Below are samples to exclude a directory from TAR Command.
TAR Command Syntax
tar czvf

TAR Command Example
tar -czvf backup.tar.gz /var/www/html

TAR Command to Exclude ‘var’ Directory
tar czvf backup.tar.gz /var/www/html –exclude=’/var/www/html/var’

TAR Command to Exclude Multiple Directories say ‘var’ and ‘media’
tar czvf backup.tar.gz /var/www/html –exclude=’/var/www/html/var’ –exclude=’/var/www/html/media’

Posted in:

Leave a Reply