Tar Command:
tar czf backup.tar.gz --exclude "wp-content/cache" public_html
Above command will archive all files and directories under public_html directory except wp-content/cache directory and create a archive file named backup.tar.gz.
Examples
- Exclude a single directory inside other directory. Create archive of all files under public_html directory ignoring all files and folders including text backup in there named
tar czf backup.tar.gz --exclude "wp-content/uploads" public_html - You can define multiple exclude in single command. For example create and archive of all files under public_html directory ignoring .svn or .git files and directories.
tar czf backup.tar.gz --exclude ".svn" --exclude ".git" public_html - To exclude a specific file define full path of the file. For example exclude “logs/access.log” inside public_html directory.
tar czf backup.tar.gz --exclude "logs/access.log" public_html - Create archive of all files under public_html directory ignoring all files and directories starting with dot ( . ) (hidden files).
tar czf backup.tar.gz --exclude "*.log" public_html
2 Comments
You are excluding through keyword. Suppose, if I want to exclude a particular path folder only.
Then what would be option?
Had the same question. The solution I found is:
1. use the absolute path to the folder you want to exclude
2. put the –exclude statement at the beginning of the command (before the “czf” stuff)