[Discuss] rsync v. cp in data migration

Richard Pieri richard.pieri at gmail.com
Thu May 23 14:41:42 EDT 2013


Greg Rundlett (freephile) wrote:
> Would  cp
>   cp -au /source/* /target
> be preferable to rsync?
>   rsync -vazn --checksum --progress --stats /source/ dest/

I wouldn't use either of these as written. cp is slow (inefficient I/O
buffering), and these rsync options don't handle sparse files and hard
links correctly.

A better way to look at migrations like this is to look at them as
backups and restores rather than file copies. The process then becomes a
matter of using the file system's preferred backup and restore tools
with a pipe in between instead of ancillary storage.

I use rsync as a last resort when the transfer has to happen between two
different kinds of file systems with incompatible backup tools. I also
use it to finish a migration if the source is live up until the last
moment before the work window opens. In these cases I use:

  rsync -avSHP --del source destination

a: archive
v: verbose processing
S: handle sparse files efficiently
H: handle hard links correctly
P: partial/progress

If FAT or NTFS are involved then the switches are "-rltvP".

I don't use -z. Compression isn't necessary for local-to-local or
local-to-remote over fast network links.

If I need a brute force, bulk copy then I still don't use cp. I use tar:

  cd source; tar cSf - . | ( cd dest; tar xpf - )

-- 
Rich P.



More information about the Discuss mailing list