Sometimes it’s the seemingly simplest things that become the biggest pain in the ass…
All I wanted to do was create a tar.gz archive of a project and exclude some files and folders.
$ man tar, followed the instructions and had little success.
tar is really finicky and differs slightly by distro… I’ll spare you the long story and just give you my working solution.
The working command
$ COPYFILE_DISABLE=true tar -c --exclude-from=.tarignore -vzf ee.tar.gz .
The break down:
COPYFILE_DISABLE=true: Prevent the ._ problem as outlined here
tar: Execute tar
-c: Set to create
–exclude-from=.tarignore: Ignore all files and folders listed in .tarignore (Just like .gitignore if you use Git)
-vzf: In order, v for verbose(show us what you’re doing), z for compress in gzip and f for compress to file
ee.tar.gzc: The name of the output file
.: Archive everything in the current working directory. You can also replace the . with * which will ignore all system files such as .htaccess.
My .tarignore file (Some are files some are directories, no trailing slash required)