Scenario
As a Solaris admin, I have a hardware failover server, and I need to mirror the web_site directory from the primary to secondary server. I use rsync running as a daemon on the "server" to mirror (synchronize) the secondary client. I do this via a cron job at midnight, so I'm never more than 24 hours behind.
This will allow you to synchronize directories and mirror from another machine as a client. Better than remote copy for me. Here's how to do it.
- Create a file called rsync in "/etc/xinet.d/"
Contents:# default: off
# description: The rsync server is a good
# addition to an ftp server, as it
# allows crc check summing etc.
service rsync
{
disable = no
log_on_failure += USERID
socket_type = stream
user = root
server = /usr/bin/rsync
server_args = --daemon
wait = no
only_from = 10.0.0.0
}
# This "only_from = 10.0.0.0" Covers this network.
# Enter the IP or range of which machine can access this sever. - Add the port in "/etc/services":
rsync 873/tcp # rsync
I would place it numerically in the 800 range. (duh) ;-)
rsync 873/udp # rsync
- You'll need a rsyncd.conf file in /etc. This file with provide your server with mappings to the directory you wish to serve.
[websites]
Other options are available:
path = /web_sites
comment = Web Site Directory for OS Xauth users = tridge, susan
The /etc/rsyncd.secrets file would look something like this:
secrets file = /etc/rsyncd.secretstridge:mypass
I don't use it. If you do, chmod the file to rw acces for root only. Make as many path mappings as you wish.
susan:herpass
- Does it work? Test it.
To see which maps you have set up in rsyncd.conf you'll need to type on the command line:% rsync localhost::
This should return:web_sites Web Site Directory
For the one we set up.
- Start your engines:
Know you are ready to do some sexy rsync'n. You do not have to set up rsync on the CLIENT machine as you did the server unless you want to (as a daemon). But if you want to "Go the other way" so to speak you will. The command and arguments for me on the CLIENT box is:% rsync -og --compress --recursive --times
[The rsync command should be one line, not three as shown here].
--perms --links --delete --verbose
admin@10.0.0.150::web_sites /web_sites/
I'm preserving owner, groups - compressing the stream, preserving times, permissions, symlinks (if any) - deleting files from the client not on the requesting client - verbose mode - I am admin@10.0.0.150 request my mapped drive in rsyncd.conf [web_sites] to update the web_site directory from the receiving server on /web_sites
You can exclude your MP3's by adding "--exclude=*.mp3" to the arguments, as many excludes as you wish.
Note that my directory is also called "/web_sites" on the CLIENT. Yours could be "Library/Webserver/Documents/" in keeping with the OS X default path. Could put it in /some_other_directory/tmp
You can -HUP xinetd to start the services, or reboot. Whatever you wish to do.
Some reading:
- http://samba.anu.edu.au/ftp/rsync/rsyncd.conf.html
- http://www.mids.org/pay/mn/801/rsync.html
- % man rsync
- % man rsyncd.conf

