With tar, I tried to compress a repository in a chroot environment with ssh, but it failed as it just compressed the symbolic link itself.
How can I compress its content?
-bash-3.00$ ls -ail
1263583 lrwxrwxrwx 1 root root 18 Apr 18 2008 mainwebsite_html -> ../../var/www/html
-bash-3.00$ tar -cjvf arch开发者_C百科ive.tar.bz2 mainwebsite_html
-bash-3.00$ ls -ail
7509101 -rw-r--r-- 1 user1 user1 136 Feb 22 08:57 archive.tar.bz2
1263583 lrwxrwxrwx 1 root root 18 Apr 18 2008 mainwebsite_html -> ../../var/www/html
From the tar(1)
man page:
-h, --dereference follow symlinks; archive and dump the files they point to
Take care of placing the "h" option in the correct place. In your example:
tar -cjvf archive.tar.bz2 mainwebsite_html
should be
tar -chjvf archive.tar.bz2 mainwebsite_html
精彩评论