rsync是否会删除目的地上已从发送方删除的文件?


14

如果rsync是从源文件中删除的,它们是否会从目标中删除文件?

例如,在源代码/ home / me中,我有三个文件:

a.txt
b.txt
c.txt

现在,我运行命令rsync -v /home/me/ user@ip.address:/home/backup,并将其复制文件a.txtb.txtc.txt/home/backup

/home/backup现在的内容

a.txt
b.txt
c.txt

如果a.txt要从中删除/home/me,将在下次运行rsync时a.txt删除/home/backup,是否需要指定一个选项,还是完全不可能?

如果有任何替代rsync的方法,也欢迎使用它们。

旁注:我已经阅读主题相关的内容,但是我无法完全理解或了解它与问题的确切关系。

Answers:


31

仅当您...选择删除选项之一时。请参阅man rsync以获取更多信息,但这是节选:

--delete                delete extraneous files from dest dirs
--delete-before         receiver deletes before xfer, not during
--delete-during         receiver deletes during the transfer
--delete-delay          find deletions during, delete after
--delete-after          receiver deletes after transfer, not during
--delete-excluded       also delete excluded files from dest dirs

这些选项的详细信息在man页面的下方。


只是要确认,这意味着如果我选择--delete,rsync会从目标中删除从源中删除的文件,从而使源和目标成为精确的镜像吗?
也许maybeharry 2015年

3
是的,但是请阅读手册页!有一些警告和提示,包括使用运行--dry-run
Sparhawk
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.