-2

I would like to sync two paths on demand (not automatically) on two CentOS servers.

The goal is to send files from server A to server B if they are different. It's about 1 gig of data in text files (so a lot of small files (.js, .php, etc.). Do I need to use something like md5deep on both servers and compare the differences on every run or is there a smarter way to do this?

(I don't mind if the first run is for example slow and becomes faster after a first index, but I have no clue if something like that exists)

1 Answers1

2

Rsync is indeed the solution for this, and "man rsync" in Google should be enough to find out the details.

But more specifically, use

rsync -az --delete /dir/on/server-a/ server-b:/target/on/server-b

Configure SSH keys so that ssh from server-a can login to server-b without a prompt for a password. The option -z will compress the data, text files will benefit from this compression. Rsync will only transmit files that have been modified. Even for modified files it will try to find unchanged parts and not transmit them again. If rsync is interrupted for whatever reason, just start the same command again and it will more or less resume where it was interrupted.

RalfFriedl
  • 3,008
  • 4
  • 12
  • 17