File Synchronization With Rsync - Mirror, Mirror, On The Wall (Page 8 of 9 )
So that's the theory. Let's now see how I applied it to my original problem (in case you've forgotten, I needed to copy the contents of a directory on our staging server to a corresponding directory on our Web server).
Let's assume that the staging server is called "medusa", and the directory to be mirrored from it on to the live server is "/usr/local/apache/htdocs/beta". The first thing to do, obviously, was to set up rsync as a daemon on one of the hosts - say "medusa" - and configure it to make the "/usr/local/apache/htdocs/beta" directory available as a module.
[web]
path = /usr/local/apache/htdocs
comment = Web Server Root
list = yes
read only = yes
Next, I needed to log in to the other end of the connection - the live Web server - and run rsync to connect to the staging server and get the latest build released by the development team to "medusa".
[webmaster@domain] $ cd /www-root/
[webmaster@domain] $ rsync --compress --verbose --delete --links--recursive --perms medusa::web/beta .
In case you're wondering, the "--compress" option compresses the data while sending it, while the "--perms" option retains the original file permissions on the destination host.
I put the two lines above into a shell script, and set it to run on a daily basis via cron. Since rsync only sends the delta when performing a copy operation, my bandwidth usage was minimal...and since the process was now largely automated, I was able to get my social life back on track.
Next: Link Out >>
More Administration Articles
More By icarus, (c) Melonfire