I am trying to create a tar file [site.tar.gz] to exclude certain folders and without the parent directory structure:

I am able to exclude folders, but when I extract, I see path from the root

tar -czvf site.tar.gz /var/www/html/site --exclude="/var/www/html/site/images" 

Do not execute the tar where you want the tar file to be created, but from the directory you want to tar:

 cd /var/www/html/site ; tar -czvf /path/to/site.tar.gz . --exclude="/var/www/html/site/images" 
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.