[TriLUG] setting up rsync

Aaron S. Joyner aaron at joyner.ws
Mon Feb 9 16:08:40 EST 2004


spain at ncssm.edu wrote:

>Anyone have any relatively simple instructions for setting up adn/or using
>rsync to synchronize html files between 2 webservers? 
> 
> 
>  _____  
>
>Sincerely,
>Jamil Hassan Spain
>NC School of Science and Mathematics | External Programs 
>Phone: 919-416-2641
>Web: www.dlt.ncssm.edu <http://www.dlt.ncssm.edu/> 
>Email: spain at ncssm.edu <mailto:spain at ncssm.edu> 
>  _____  
>
> 
> 
>  
>
A crontab entry something like this should do the trick:
*/2 * * * * /usr/local/bin/rsync -a --delete -e ssh --exclude 
'files/*/to/exclude' /path/to/local/files/ 
<remotemachine>:/remote/path/to/store/

This will sync the directory on the local host with the remote host 
every 2 minutes.  It will always consider the local host to be 
authoritative, and if something is deleted locally, it will delete it 
remotely on the next sync.  If something is changed on the remote side, 
it will get blown away on the next sync.

A few things to consider:

If you use the "-e ssh" switch you'll need to ensure that you can login 
to the remote host without requiring a password, as the user that the 
cron job is running as.  For more information `man sshd` - that's beyond 
the scope of your question.

If you don't use "-e ssh" (and thus don't funnel it over an ssh tunnel) 
you'll need to setup rsyncd on the remote host.  Haven't done it 
personally, as I've always done it the other way.

I just saw David M.'s post right before I went to hit send.  Note that 
-a preserves permissions.

As always, `man rsync` for more info, and some relatively good 
straight-forward examples.

Aaron J.




More information about the TriLUG mailing list