Exclude a folder on tar
Hi
I want to backup the contents of the folder: Code:
/home/username/public_html/ So i cd here: Code:
cd /home/username Code:
tar -cpvzf /home/username/sitefiles.tgz --exclude=/home/username/public_html/uploads public_html Code:
tar -cpvzf /home/username/sitefiles.tgz public_html --exclude=/home/username/public_html/uploads Code:
tar --exclude=/home/username/public_html/uploads -cpvzf /home/username/sitefiles.tgz public_html Code:
tar -cpvzf /home/username/sitefiles.tgz public_html --exclude=./home/username/public_html/uploads Code:
tar -cpvzf /home/username/sitefiles.tgz public_html --exclude="/home/username/public_html/uploads" Any ideas? Tested on Centos and Ubuntu 64bit servers :( |
You do not have ssh listed anywhere in the commands above. What part is this playing in the issuing of the command?
As far as the tar command goes, you need to remember the man page advises it is a pattern and once in your home directory, there will not be a full path to your directory available. Try: Code:
tar -cpvzf /home/username/sitefiles.tgz --exclude=uploads public_html |
The key idea from your OP is...
Quote:
Quote:
It also happens that the path to the files to exclude are matched as character strings, not as absolute filesystem paths, so they must be expressed in the same context as the included files. Because you are including public_html as a relative path, the exclude path must also be relative. So this will not work... Code:
tar -cpvzf /home/username/sitefiles.tgz public_html --exclude=/home/username/public_html/uploads Code:
tar -cpvzf /home/username/sitefiles.tgz public_html --exclude=./home/username/public_html/uploads Nor this... Code:
tar -cpvzf /home/username/sitefiles.tgz public_html --exclude=public_html/uploads Code:
tar -cpvzf /home/username/sitefiles.tgz public_html --exclude=public_html/uploads/* |
This one works for me:
Code:
tar -cpvzf /home/username/sitefiles.tgz public_html --exclude=public_html/uploads/* |
How can i do the opposite now?
Exclude all fies and folders and tar only the /public_html/uploads files and subfolders there? Thanks |
Just explicitly tell it what to tar
Code:
tar -cpvzf /home/username/sitefiles.tgz public_html/uploads Code:
tar -cpvzrf /home/username/sitefiles.tgz public_html/uploads |
Thanks !!!
|
All times are GMT -5. The time now is 09:29 AM. |