我想更新备份磁盘上的目录,并将新内容添加到源中,当然rsync 太慢cp -a 可以解决问题,但效果不佳;cp -u 应该不会影响现有文件。但是,如果我检查它们一起执行的操作(cp -auv),我发现很多文件被复制到了据我所知已经存在的目录中。
看看cp 手册这两个选项似乎并不矛盾。所以我可能是错的,cp 做的是正确的。无论如何,一些额外的工作并不重要,因为 cp 速度很快。
或者它们在实践中是矛盾的,因为源和目标之间的标准总是存在一些细微的差异?我不是第一个被 -u 弄糊涂了。
‘--archive’
Preserve as much as possible of the structure and attributes of the original files in the copy (but do not attempt to preserve internal directory structure; i.e., ‘ls -U’ may list the entries in a copied directory in a different order). Try to preserve SELinux security context and extended attributes (xattr), but ignore any failure to do that and print no corresponding diagnostic. Equivalent to -dR --preserve=all with the reduced diagnostics.
‘--update’
Do not copy a non-directory that has an existing destination with the same or newer modification time. If time stamps are being preserved, the comparison is to the source time stamp truncated to the resolutions of the destination file system and of the system calls used to update time stamps; this avoids duplicate work if several ‘cp -pu’ commands are executed with the same source and destination. If --preserve=links is also specified (like with ‘cp -au’ for example), that will take precedence. Consequently, depending on the order that files are processed from the source, newer files in the destination may be replaced, to mirror hard links in the source.