如何在符号链接下压缩文件夹
How to gzip a folder under a symlink
我正在尝试 gzip 所有子目录和文件,folder.The 一个特点是我压缩的文件是符号 link 我网站的最后一个版本
filename=$(date '+%Y%m%d')
cd /home/site
tar -zcvf $filename.tar.gz current/
scp $filename.tar.gz server:~/backups/production
rm $filename.tar.gz
当操作结束,我打开压缩文件夹。我说的是文件夹的 symlink 而不是它的内容。哪里错了?
这是预期的行为。如果要取消引用符号链接,则需要在创建存档时指定 -h
标志。来自 tar
manual:
Normally, when tar archives a symbolic link, it writes a block to the
archive naming the target of the link. In that way, the tar archive is
a faithful record of the file system contents. When --dereference
(-h
) is used with --create
(-c
), tar archives the files symbolic
links point to, instead of the links themselves.
我正在尝试 gzip 所有子目录和文件,folder.The 一个特点是我压缩的文件是符号 link 我网站的最后一个版本
filename=$(date '+%Y%m%d')
cd /home/site
tar -zcvf $filename.tar.gz current/
scp $filename.tar.gz server:~/backups/production
rm $filename.tar.gz
当操作结束,我打开压缩文件夹。我说的是文件夹的 symlink 而不是它的内容。哪里错了?
这是预期的行为。如果要取消引用符号链接,则需要在创建存档时指定 -h
标志。来自 tar
manual:
Normally, when tar archives a symbolic link, it writes a block to the archive naming the target of the link. In that way, the tar archive is a faithful record of the file system contents. When
--dereference
(-h
) is used with--create
(-c
), tar archives the files symbolic links point to, instead of the links themselves.