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/
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!
Your email is never published nor shared. Required fields are marked *
You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
how to setup rsync with cron
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:
2. Generate an ssh key pair to be used only for rsync among servers
With Mac, it’s as simple as:
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
Basically that command connects over SSH to the other server every minute and ‘rsyncs’ with the target directory.
That’s it!