Solved

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

Posted on 2008-06-18
3
1,105 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
  • 2
3 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 500 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…

932 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now