![rsync是否会删除目的地上从发送端删除的文件?](https://linux22.com/image/79694/rsync%E6%98%AF%E5%90%A6%E4%BC%9A%E5%88%A0%E9%99%A4%E7%9B%AE%E7%9A%84%E5%9C%B0%E4%B8%8A%E4%BB%8E%E5%8F%91%E9%80%81%E7%AB%AF%E5%88%A0%E9%99%A4%E7%9A%84%E6%96%87%E4%BB%B6%EF%BC%9F.png)
如果文件从源中删除,rsync 是否也会从目标中删除文件?
例如,假设在源 /home/me 中我有三个文件:
a.txt
b.txt
c.txt
现在,我运行该命令,它将文件、和复制到。rsync -v /home/me/ [email protected]:/home/backup
a.txt
b.txt
c.txt
/home/backup
现在的内容/home/backup
是
a.txt
b.txt
c.txt
如果我要从a.txt
中删除/home/me
,下次运行 rsync 时会a.txt
被删除/home/backup
,是否需要指定一个选项,还是完全不可能?
如果有任何 rsync 的替代方案可以做到这一点,我们也欢迎它们。
答案1
仅当您...选择删除选项之一。看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
。