Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-14-2009, 03:12 AM   #1
LQ Newbie
Registered: Mar 2007
Posts: 3

Rep: Reputation: 0
How to have two folders (two machines) constantly synced

I got 2 web servers on which I got two web applications.
My goal is to have the "Session" folder and other temp folders constantly in sync between the machine.

I started out using cron and rsync but it's not "real-time" enough as I can only cron every one minute or so.

Can anyone tell me of a smarter way to constantly keep two folders on two machines (same IP cluster) in sync?

Maybe a shell script running always and running rsync?

Old 07-14-2009, 03:16 AM   #2
Senior Member
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,275

Rep: Reputation: 148Reputation: 148
chek about drbd and heartbeat
Old 07-14-2009, 03:18 AM   #3
LQ Newbie
Registered: Jul 2009
Distribution: Ubuntu 9.04
Posts: 1

Rep: Reputation: 1
I think you can use sshfs, which allows you to mount remote directory through ssh. So you will have what you want + secure channel
Old 07-14-2009, 03:18 AM   #4
Registered: May 2006
Location: BE
Distribution: Debian/Gentoo
Posts: 412

Rep: Reputation: 48
Well, if it works by syncing all of it using rsync, then why not invest in a NAS and mount the same web dir on both systems... or start looking into clusters.

Just a thought.
Old 07-14-2009, 03:53 AM   #5
LQ Newbie
Registered: Mar 2007
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks guys!
DRBD and hearbeat are an overkill for my needs. The reason I keep two machines is for load balancing mainly (simple round robin).
The heartbeat overhead and HA solution is not my goal and I rather keep it simple.
NAS is a great solution but costs too much to rent.

SSHFS is really cool (never saw it before) but it reads from one machine (while I want both to keep a full copy of the data).

Is there a way to keep rsync running in an ever lasting loop?
Old 07-14-2009, 03:54 AM   #6
Gentoo support team
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,074

Rep: Reputation: 387Reputation: 387Reputation: 387Reputation: 387
I would just mount it remotely, so there's no need to sync.

If you prefer to sync (generating useless traffic and wasting extra storage space), then look into inotify. A simple bash script using inotifywait will be all you need for this. Simple example:

inotifywait --monitor --event create --event modify --format "%f" ~/tmp | while read file
  echo "$file"

Last edited by i92guboj; 07-14-2009 at 03:58 AM. Reason: example added
Old 07-14-2009, 04:01 AM   #7
LQ Guru
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295

I use Unison to my great satisfaction. Easy to setup and configure without any hassle.

Kind regards,

Old 07-14-2009, 06:54 AM   #8
LQ Newbie
Registered: Mar 2007
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks All!
I used SSHFS, worked like a charm!

You guys rock!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
copy folders between machines without password deepika5 Linux - Networking 2 04-24-2008 09:07 AM
Share folders with Windows machines over network furcatus Linux - Networking 2 12-08-2005 12:08 PM
Synced my UX50 mjolnir Member Success Stories 0 07-07-2005 03:37 PM
flash not synced John5788 Linux - General 0 04-15-2004 01:11 AM
Moving Mozilla mail folders between machines rharvey@cox Linux - Software 6 02-13-2004 10:56 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:22 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration