Link to home
Start Free TrialLog in
Avatar of cmercado_miranda
cmercado_miranda

asked on

Need a script to continuously sync files from two remote machines via rsync and sftp

Hello,
I'm setting up two servers and I need to configure one of them to monitor two folders and sync everything of that folder to another server via sftp. I was thinking of using rsync to do this.

This is what I need.

Server one (main server that has all the uploaded files) - IP: 192.168.1.125

Folders that need to be synced:
/var/www/images_uploads/
/var/www/video_uploads/

These to folders need to be synced continuously to another server via sftp using rsync

Server Two (synced server) - IP: 192.168.1.126
Images will be saved to: /var/www/website/images/
Videos will be saved to: /var/www/website/videos/

How can I do this? is there a place online were I can find a tutorial on how to accomplish this? or maybe already a script that I could modify to my needs?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Tintin
Tintin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cmercado_miranda
cmercado_miranda

ASKER

Thanks Tintin,

Just to make sure... that's for maintianing two synced servers, right. How about if I want to sync one way only. From my main server (192.168.1.125) to copy to the other server (192.168.1.126). What would be the params to be changed? What if I want to set login credentials in that same command line (so this way I can create an automatic cron job) what extra params do I need to add?
It's a one way sync.  To automate the process you just need to setup ssh keys.