如果文件从源中删除,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
。