Solved

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

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

By default, Carbonite Server Backup manages your encryption key for you using Advanced Encryption Standard (AES) 128-bit encryption. If you choose to manage your private encryption key, your backups will be encrypted using AES 256-bit encryption.
This article is an update and follow-up of my previous article:   Storage 101: common concepts in the IT enterprise storage This time, I expand on more frequently used storage concepts.
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
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…

710 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