cp -au / cp --archive --update是否矛盾?


1

我要更新备份磁盘上的目录,并将新内容添加到源中,当然rsync太慢了。cp -a可以达到目的,但是却是推土机;cp -u应该保留现有文件。但是,如果检查一下他们正在一起做什么(cp -auv),我会看到大量文件被复制到AFAIK已经存在的目录中。

看看cp手册,这两个选项似乎并不矛盾。所以我可能是错的,而cp做正确的事。无论如何,多余的工作并不重要,因为cp是如此之快。

也许它们在实践中是矛盾的,因为-a标准在源和目的地之间总是存在一些小的差异?我不会是-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.
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.