Linux – How to Copy Large Number of Files Quickly Between Servers

file-transferlinuxperformance

I need to transfer a huge amount of mp3s between two serves (Ubuntu).
By huge I mean about a million files which are on average 300K.
I tried with scp but it would have taken about a week. (about 500 KB/s)
If I transfer a single file by HTTP, I get 9-10 MB/s, but I don't know how to transfer all of them.

Is there a way to transfer all of them quickly?

Best Answer

I would recommend tar. When the file trees are already similar, rsync performs very well. However, since rsync will do multiple analysis passes on each file, and then copy the changes, it is much slower than tar for the initial copy. This command will likely do what you want. It will copy the files between the machines, as well as preserve both permissions and user/group ownerships.

tar -c /path/to/dir | ssh remote_server 'tar -xvf - -C /absolute/path/to/remotedir'

As per Mackintosh's comment below this is the command you would use for rsync

rsync -avW -e ssh /path/to/dir/ remote_server:/path/to/remotedir