I just built an environment which a few servers that requires rsync to keep a directory synchronized among servers.
Here are the steps.
1. On every server install rsync:
sudo yum install rsync
2. Generate an ssh key pair to be used only for rsync among servers
With Mac, it’s as simple as:
ssh-keygen -t rsa
Make sure no password is associated with the SSH keypair
3. Add the keypair for my rsync runner user
Place id_rsa in /home/runner/.ssh/id_rsa with the right ownership (runner:runner) and permissions (0400)
4. Configure cron tab for the runner user
crontab -e
# rsync
* * * * * rsync -azq –delete -e ssh /sites/aycron.com/shared/public/ webcloud2:/sites/aycron.com/shared/public/
Basically that command connects over SSH to the other server every minute and ‘rsyncs’ with the target directory.
That’s it!
