LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how can I gzip directory without following symbolic links (https://www.linuxquestions.org/questions/linux-newbie-8/how-can-i-gzip-directory-without-following-symbolic-links-942096/)

tiroloz 04-27-2012 09:32 AM

how can I gzip directory without following symbolic links
 
I am using CentOS 6.2 and I am trying to make a backup of my website directory. The directory has a symbolic link to user_files which are located at /home/user_files. Here is the listing:

[root@web04 uploads]# ls -lrt
total 0
lrwxrwxrwx. 1 root root 16 Apr 13 01:29 user_files -> /home/user_files

The man pages for gzip say this:

" Gzip will only attempt to compress regular files. In particular, it will ignore symbolic links."

So I tried to do the following gzip command:
gzip -cvr mysite > mysite.gz

But whenever I do this, I can see it diving into the user_files directory and trying to zip up every file in the site. What am I doing wrong?

crabboy 04-27-2012 03:21 PM

tar will not follow sym links, it will use gzip compression on the fly with the z option.
Code:

$ tar /webdir -zcvf webdir.tar.gz


All times are GMT -5. The time now is 09:45 PM.