You can't put the complete path into -C, if you want to tar the content of www
. Do this instead:
tar -pczf domain.com.tar.gz -C /var/www/domain.com/public_html/www .
That way 'www' is the directory to be tarred but omited itself by including it into the -C path. You would than later extract all files of the 'www' directory.
In addtion to your edit (exclude) it must look like this:
tar --exclude=tmp -pczf domain.com.tar.gz -C /var/www/domain.com/public_html/www .
EDIT
According to your wishes, I found a funny but working solution. You exclude the dirs you want with exclude (see the man page of your tar, there are some with --no-recurse
option, too) and you will have no ./
syntax at all:
ls /var/www/domain.com/public_html/www | xargs tar --exclude=tmp -C /var/www/domain.com/public_html/www -pczf domain.com.tar.gz
The way you give the filenames to the input, is the way tar is storing it. So it is even possible with -C
to store the files without ./
but you need to pipe the list of ls
with | xargs
to tar.....