-1

I want to sync files in dir1 and dir2 (two different servers).

I do not care if the file sizes or modification times differ.

EXAMPLE: dir1 contains file1, file2, file3, file4, and dir2 contains file2, file3, file5

I want file5 copied to dir1, and file1, file4 copied to dir2.

Note that file2 sizes differ, as do file3 modification times, but I do not care. My network is private as well, so I do not want any security overhead.

Which would be fastest:

rsync, scp, or cp over NFS mount? And, precisely, what is the corresponding command line?

Corepuncher
  • 191
  • 1
  • 3
  • 9
  • Can you please elaborate on your goal here? What problem are you trying to solve? Unless your data is relatively large, I don't think your going to see a substantial difference in transfer times. It all depends on your intermediary network connections and available bandwidth. – Mike B Feb 23 '15 at 09:06

1 Answers1

0

It's largely academic, because your limiting factor will most likely be your network bandwidth. The only thing to watch for really, is sizes of files vs numbers of operations - lots of small files will result in lots of small copy operations.

But as it stands - it's hard to say for sure what will be 'fastest' because 'it depends'.

I would be surprised to find you had much in the way of problems with rsync, for the simple reason that it'll check if it needs to do anything before doing any copying. There's not much that's more efficient than not copying things you don't need.

If you've a lot of small files then you may find tar does it better though - tar is designed for writing to tapes, so is quite good for streaming a directory structure across a network. e.g.

tar cvfz - ./path_to_copy | ssh $remotehost "( cd $destination && tar xvfz - )"

Sobrique
  • 3,747
  • 2
  • 15
  • 36
  • The reason I ask is because I am copying small files to a cache. My script takes 0.6 seconds to run without an existing cached copy, but 0.23 seconds with. So, if the difference between NFS cp and rsync is in the hundredths of second, then it does not matter which method. If we start getting into tenths of seconds then it defeats the purpose of caching these files. rsync seems cleaner overall. – Corepuncher Mar 02 '15 at 00:34