Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2008-06-18
3
Medium Priority
?
1,113 Views
Last Modified: 2013-12-02
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
0
Comment
Question by:cmercado_miranda
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 1500 total points
ID: 21816537
A simple matter of doing
rsync -av -e ssh /var/www/images_uploads/* 192.168.1.126:/var/www/website/images/
rsync -av -e ssh /var/www/video_uploads/* 192.168.1.126:/var/www/website/videos/

Open in new window

0
 

Author Comment

by:cmercado_miranda
ID: 21834698
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?
0
 
LVL 48

Expert Comment

by:Tintin
ID: 21834822
It's a one way sync.  To automate the process you just need to setup ssh keys.

0

Featured Post

Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article will include the best Data Recovery Tools along with their Features, Capabilities, and their Download Links. Hope you’ll enjoy it and will choose the one as required by you.
Microsoft will be releasing the Windows 10 Creators Update in just a matter of weeks. Are you prepared? Follow these steps to ensure everything goes smoothly and you don't lose valuable data on your PC.
This tutorial will walk an individual through the process of configuring basic necessities in order to use the 2010 version of Data Protection Manager. These include storage, agents, and protection jobs. Launch Data Protection Manager from the deskt…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question