Solved

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

Posted on 2008-06-18
3
1,104 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

If, like me, you have a lot of Dell servers in the estate you manage this article should save you a little time. When attempting to login to iDrac on any server I would be presented with two errors. The first reads "Do you want to run this applicati…
Microservice architecture adoption brings many advantages, but can add intricacy. Selecting the right orchestration tool is most important for business specific needs.
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 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…

758 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

18 Experts available now in Live!

Get 1:1 Help Now