Jake Johnson <[EMAIL PROTECTED]> wrote:

>I am trying to mirror a few linux boxes with rsync and I would like to run
>it as a cron.  Any suggestions?

Scheduling rsync with via cron is pretty straightforward.  I have a couple 
of bash shell scripts that run rsync.

You have a couple of options for using rsync.  If the machines are on the 
same LAN and you're not terribly concerned about data encryption, rsync can 
be setup as a server.  Rsync uses a challenge-response authentication 
method but the data is normally sent unencrypted.  If you want the data 
stream encrypted, then using ssh as a transport method is probably 
safer.  I've haven't used ssh with rsync before but I imagine it's similar 
to what I'm working on now, namely running bru over ssh.

To setup an rsync server you'll need a line in /etc/inetd.conf like so:

rsync   stream  tcp     nowait  root    /usr/bin/rsync rsyncd --daemon

and a line in /etc/services:

rsync           873/tcp         # rsync server

I think you can have rsync listen on a different port if you want.  There's 
also an rsyncd config file /etc/rsyncd.conf that looks something like so:

[sharename]
         path = /some/pathname
         uid = 0
         gid = 0
         read only = yes
         hosts allow = yourhost.yourdomain

If you've ever used samba, the config file and options are very similar, 
which should come as no surprise since rsync was written by some of the 
same people.

If you want to use it over ssh you'll need to setup ssh so that you can 
login remotely without password authentication like so:  (Note:  I'll 
assume for the moment that you want to run rsync as root.  It's probably 
easiest to do so unless you're sure all the files/directories to be 
synchronized can be read by a regular user.  If this is the case, 
substitute the regular username for root below.)

1) Run ssh-keygen as root on the host that will be initiating the rsync/ssh 
connection.  Don't enter a passphrase when prompted - leave it blank, 
otherwise you'll have to enter the passphrase when connecting via ssh, 
which defeats the purpose.  This will create a file ~/.ssh/identity.pub

2) Copy the file ~/.ssh/identity.pub to the host that you'll be connecting 
to with rsync/ssh.  It should be put in ~/.ssh/authorized_keys.  If 
authorized_keys already exists, cat or cut/paste the two files 
together.  (Be sure the permissions on authorized_keys are 0600 the files 
owner & group is root.)

3) You should now be able to login as root on the first host and ssh to the 
second host without having to type in a password.  Yes, it feels wrong at 
first (it still does to me), but it's much safer than the "r-" commands and 
the authorized_keys file in effect says "Root is allowed to connect via ssh 
without a password from these hosts only."  When using ssh from another 
host, you'll still have to type in the password.

4) You should also now be able to execute a command on the remote host over 
ssh.  Try it by typing something like 'ssh [hostname] ls -l'.  This should 
connect to the remote server via ssh and run the command 'ls -l'.  If this 
works you should be able to use rsync with the '-e ssh' switch.

Note:  I haven't actually used rsync in this fashion, so you'll have to try 
it and let me know, but this is what I've done to make bru work over ssh.

I've found rsync to be quite useful.  If you want more information about 
setting up an rsync server or the scripts I use, let me know.

I hope this all makes sense, it's been a long day and I've got a major 
headache...  :-(

-Eric



Eric Sisler
Library Computer Technician
Westminster Public Library
Westminster, CO, USA
[EMAIL PROTECTED]

Linux - don't fear the Penguin.
Want to know what we use Linux for?
Visit http://gromit.westminster.lib.co.us/linux


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.

Reply via email to