只复制整个文件

有什么方法可以将目录从一个文件系统复制到另一个文件系统,但是如果我们在目标文件系统上的磁盘空间不足时删除部分文件?
我search了cprsync手册,但没有find任何东西; 我可以在一个shell脚本中做到这一点,但如果可能的话,要避免它。
目前我做:

 cp -r /source /dest 

要么

 rsync -avr /source /dest 

如果你看看rsync手册,你可以阅读:

 --partial By default, rsync will delete any partially transferred file if the transfer is interrupted. In some circumstances it is more desirable to keep partially transferred files. Using the --partial option tells rsync to keep the partial file which should make a subsequent transfer of the rest of the file much faster. 

这意味着你不必担心部分传输。

你可以确保--partial-dir=DIR选项。 然后,如果要删除部分传输的文件,则可以删除此目录下的所有文件。

最好的方法是在复制开始之前检查可用空间(多余的空间)。

cp的正常行为是删除不完整的文件。