So what’s the difference between
cp -R and
-R If source_file designates a directory, cp copies the directory and the entire subtree connected at that point. If the
source_file ends in a /, the contents of the directory are copied rather than the directory itself. This option also causes
symbolic links to be copied, rather than indirected through, and for cp to create special files rather than copying them as
normal files. Created directories have the same mode as the corresponding source directory, unmodified by the process’
In -R mode, cp will continue copying even if errors are detected.
Note that cp copies hard-linked files as separate files. If you need to preserve hard links, consider using tar(1),
cpio(1), or pax(1) instead.
- recursively copy
- copy symlinks
- create special files rather than copying them as
- directories have same mode as source
man rsync and looking at
- -p, –perms preserve permissions
- -v, –verbose increase verbosity
- -z, –compress
With this option, rsync compresses the file data as it is sent to the destination machine, which reduces the amount of
data being transmitted — something that is useful over a slow connection.Note that this option typically achieves better compression ratios than can be achieved by using a compressing remote
shell or a compressing transport because it takes advantage of the implicit information in the matching data blocks that
are not explicitly sent over the connection.
- -a, –archive
This is equivalent to -rlptgoD. It is a quick way of saying you want recursion and want to preserve almost everything (with -H being a notable omission). The only exception to the above equivalence is when –files-from is specified, in which case -r is not implied.Note that -a does not preserve hardlinks, because finding multiply-linked files is expensive. You must separately specify -H.
- -r, –recursive
This tells rsync to copy directories recursively. See also –dirs (-d).
This tells rsync to look for hard-linked files in the transfer and link together the corresponding files on the receiving side. Without this option, hard-linked files in the transfer are treated as though they were separate files.
Note that rsync can only detect hard links if both parts of the link are in the list of files being sent.
See also How do you copy a directory?