Rsynch 和 SSH:仅在从源重命名时重命名文件夹
我已经阅读 rsync 文档几个小时了,但我不知道如何向 rsync 传达如何在源文件夹重命名时仅重命名(而不是重新上传文件夹及其内容)目标文件夹。
我使用 SSH 连接到目标,本地文件夹是源,远程服务器是目标。如果我重命名包含文件的文件夹,rsync 会自动重新上传源文件夹的所有内容。我没有使用 rsync 的服务器部分,如果这样做的话也许它会起作用?
我在 lftp 中遇到了相同的行为,并且该工具似乎没有这些选项。即使它基于文件的日期规则,重命名的文件夹内的文件也会被删除/重新上传。
如果有人知道如何管理这个,请提前致谢:)
I have been reading the rsync documentation for a few hours, but I can't figure out how to convey to rsync how to only rename (and not re-upload folder and it's content) destination folders when they are renamed at the source.
I'm connecting to the destination with SSH, and the local folder is the source -- and the remote server is the destination. If I rename a folder containing files, rsync automatically re-uploads all the content of the source folder. I'm not using the rsync's server part, maybe it will works if were to do that ?
I have encountered the same behavior with lftp, and this tool doesn't seem's to have these options. Even if it is based on the file's date rule, files inside the renamed folder are removed/re-uploaded.
Thanks in advance if someone knows how to manage this :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我一直在寻找类似的东西。
到目前为止,我找到的最佳解决方案位于:
http:// /serenadetoacuckooo.blogspot.com/2009/07/rsync-and-directory-renaming.html
它基本上提到在每个文件夹中包含一个指示文件夹名称的元文件。
本质上,您需要检查该文件的目录名,并且仅当它们相同时才进行 rsync(否则,发出远程重命名命令。)
这取决于您使用 rsync 的范围,但我希望这些信息可以帮助您。
I've been looking for something similar.
so far, the best solution I have found is at:
http://serenadetoacuckooo.blogspot.com/2009/07/rsync-and-directory-renaming.html
It basically mentions including a meta-file in each folder that indicates the folder's name.
Essentially, you would want to check that file with the directory name, and rsync only if they are the same (otherwise, issue a remote rename command.)
It depends on the scope of what you're using rsync for, but I hope that this information can help you.
rsync 或任何其他程序如何知道重命名的构成是什么?如果两个目录是非常相似的候选目录,并且 rsync 猜测其中一个目录可能是之前目录的重命名,该怎么办?这是不可能的。我认为您必须再次上传所有内容。
你知道 --delete 选项,对吧:
--delete 删除发送端不存在的文件
另请注意 --force 选项:
--force 强制删除目录,即使不为空
How would rsync or any other program know what constitutes renamed? What if two directories are very similar candidates and somehow rsync guesses maybe either one could be a rename of what went before? It's not possible. I think you're stuck with uploading everything again.
You know about the --delete option, right:
--delete delete files that don't exist on the sending side
Note also the --force option:
--force force deletion of directories even if not empty