Copy or rsync command

前端 未结 8 1443
广开言路
广开言路 2021-01-30 03:42

The following command is working as expected...

cp -ur /home/abc/* /mnt/windowsabc/

Does rsync has any advantage over it? Is there a better way

8条回答
  •  粉色の甜心
    2021-01-30 04:16

    rsync is not necessarily more efficient, due to the more detailed inventory of files and blocks it performs. The algorithm is fantastic at what it does, but you need to understand your problem to know if it is really going to be the best choice.

    On a very large file system (say many thousands or millions of files) where files tend to be added but not updated, "cp -u" will likely be more efficient. cp makes the decision to copy solely on metadata and can simply get to the business of copying.

    Note that you might want some buffering, e.g. by using tar rather than straight cp, depending on the size of the files, network performance, other disk activity, etc. I find the following idea very useful:

    tar cf - . | tar xCf directory -
    

    Metadata itself may actually become a significant overhead on very large (cluster) file systems, but rsync and cp will share this problem.

    rsync seems to frequently be the preferred tool (and in general purpose applications is my usual default choice), but there are probably many people who blindly use rsync without thinking it through.

提交回复
热议问题