View Single Post
  #2 (permalink)  
Old 22-04-2006, 12:41 AM
nixcraft's Avatar
nixcraft nixcraft is offline
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 245 Times in 184 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Replace your rsync command (assuming that you want to sync server1 with local server2)

Code:
rsync -avz server1:/mail server2:/mail
with (type command on server2)
Code:
rsync -avrR --links --rsh=/usr/bin/ssh server1:/mail :/mail
To avoid password prompt you need to setup ssh-keys, so on server2 type following commands:
Code:
ssh-keygen -t rsa
ssh you@server1 "mkdir .ssh"
scp .ssh/id_rsa.pub you@server1:.ssh/authorized_keys2
Now you can login to server1 from server2 without password. Now setup cron job using following script (save script on server2):
Code:
#!/bin/bash
MASTER="server1"
DIR="/mail"
LDIR="/mail"
SSH="/usr/bin/ssh"
rsync -avrR --links --rsh=$SSH $MASTER:$DIR $LDIR
Cron job
Setup cronjob using following syntax:
Code:
1 18,19,20,21,22,23,0,1,2 * * * /path/to/script.sh
Script.sh will run at 6:01pm, 7:01pm, 8:01pm ... 2:01am

Read following docs for more info:

How do I add jobs to cron under Linux or UNIX oses
SSH Public key based authentication - How-to?
How do I sync data between two Load balanced Linux/UNIX servers?

if you have more question just reply back and we will be glad to assist you
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote