Rsync 只创建符号链接 [英] Rsync create symbolic links only

查看:31
本文介绍了Rsync 只创建符号链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前的 rsync 运行良好.它将我的所有文件从一个目录复制到另一个目录.唯一的事情是它正在物理复制文件.

I currently have rsync working well. It copies all my files from one directory to another directory. The only thing is it is physically copying the files.

我有很多大文件,我不想复制所有文件.我只想在新目录中创建一个符号链接,以便我可以在网页上提供数据.源目录中有一些我不想让公众看到的脚本和文件.我正在将安全数据移动到网络根目录(目标).

I have a lot of large files that I don't want to have a duplicate of all the files. I just want to create a symbolic link in the new directory so that I can serve the data on a webpage. The source directory has some scripts and files I don't want the public to see. I'm moving the safe data to the web root (destination).

我希望 rsync 做的是源目录中的任何新文件都会创建指向目标的链接.这样我就不会像现在一样用完我的硬盘空间.除了对它进行符号链接方面之外,我所拥有的一切都很完美.有没有办法让 rsync 跟踪并创建符号链接?

What I would like rsync to do is any new files in the source directory would create links into the destination. That way I am not using up my hard drive space like I currently am doing. What I have works perfect except for doing the symbolic link aspect to it. Is there a way to have rsync track and create symbolic links?

rsync -aP --exclude="file.sql" --exclude="*~" --exclude=".*" --exclude="*.sh" . ${destination}

推荐答案

它不是符号链接,但您可能可以使用 --link-dest=DIR.它会创建一个硬链接,该链接将为同一文件创建一个新名称.只要满足以下条件,这将类似于软链接:

It's not a symlink, but you might be able to work with --link-dest=DIR. It creates a hard link which will create a new name for the same file. This will behave similarly to a softlink as long as:

  • 两个文件都在同一个文件系统中
  • 您不打算删除原始文件而不是副本(符号链接会中断,但硬链接不会)
  • 您没有明确检查它是否是软链接

这篇关于Rsync 只创建符号链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆