0

I would like a simple tool for syncing two folders on remote servers...

Utopically, I only need an OS catchable trigger (or something like that) that could be used to fire rsync automatically ?

Is there anything of the sort, or a simple tool capable of doing this ?

rsync each minute is not at all an elegant solution to the problem ... i would like to call rsync each time a file is written/deleted in any one of the servers, in a specific folder...

the goal is to easily maintain to remote folders in sync

update: maybe something like gamin... ?

thanks !

arod

arod
  • 632

4 Answers4

3

In my answer to this question, I suggested incron. It's easy to set up system-wide and user-specific config files in a manner similar to cron. You can specify scripts that will be run when filesystem events are triggered. It uses the Linux kernel inotify API. You might take a look at it and see if it works for you.

2

Try inotify. For your relative simple requirements this should be best suited.

An example script:

while { inotifywait -e create -e delete /directory2watch; }; do
  echo rsync -avz /directory2watch
done

Or something like that.

With inotify you have access to those events:

  • access – file was accessed
  • modify – file was modified
  • attrib – file attributes changed
  • close_write – file closed, after being opened in writeable mode
  • close_nowrite – file closed, after being opened in read-only mode
  • close – file closed, regardless of read/write mode
  • open – file was opened
  • move – a file within watched directory was moved
  • create – a file was created within watched directory
  • delete – a file was deleted within watched directory
  • delete_self – the watched file was deleted
  • unmount – file system on which watched file exists was unmounted
weeheavy
  • 4,149
  • 1
  • 30
  • 41
1

It seems like DRBD will do just what you need. It works at the block device level, so if you don't want to maintain a separate partition for this synchronized data, you can just create a disk image and mount it loopback, using DRBD to keep things in sync with the remote server.

EEAA
  • 110,608
0

The obvious solution here is afs

There all sorts of complications using DRBD on anything but a small LAN with high levels of connectivity between nodes.

But you could roll your own solution using inotify

symcbean
  • 23,767
  • 2
  • 38
  • 58