1

I want to update a directory on a backup disk with new content added to the source, and of course rsync is too slow. cp -a does the trick but is a bulldozer; cp -u should leave existing files alone. However if I inspect what they're doing together (cp -auv) I see plenty of files being copied to the directory which AFAIK were already there.

Looking at the cp manual the two options don't seem in contradiction. So I'm probably wrong, and cp is doing the right thing. Some excess work doesn't matter so much anyway because cp is so fast.

Or maybe they are contradictory in practice, because there is always some small difference by -a standards between source and destination? I wouldn't be the first confused by -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.

0

You must log in to answer this question.

Browse other questions tagged .