Home   >>   Lsyncd   >>   Synchronize Local Directories With a or Several Remote Machines
Synchronize Local Directories With a or Several Remote Machines PDF Print E-mail
( 0 Votes )
How To - Lsyncd
Written by Christian Foronda   
Wednesday, 01 September 2010 13:40

lsyncd is a program that uses rsync to synchronize local directories with a or several remote machine(s) running rsyncd. Lsyncd watches multiple directory trees through inotify. On startup it will rsync all directories with the remote host(s), and then sync single directories by collecting the inotify events. This tool is a lightx-weight live mirror solution.

Install lsyncd on RHEL / CentOS Linux:

	# yum install lsyncd

Sample usage:

Watch and rsycn's the local directory /var/www/ with all subdirectories and transfers them to 'remotehost' using the rsync-share 'wwwshare'.

	#  /usr/sbin/lsyncd /var/www/ remotehost::wwwshare/

Rsync/watch '/var/www', but it excludes files and directories from '/etc/lsycnd/exclude'. Additionally this example lsyncd will not fork, and log to stdout/stderr instead.

	#  /usr/sbin/lsyncd --no-daemon --exclude-from /etc/lsycnd/exclude /var/www/ remotehost::wwwshare/

This special target will scan through all directories in /home and syncs all www subdirectories of the users to wwwshare in the subdirectory foobar. The user peter having his local data in /home/peter/www/ will have it rsynced to ::wwwshare/foobar/peter/.

	# /usr/sbin/lsyncd %userwww remotehost::wwwshare/foobar/

Limitations:
Be aware that the kernel limits the number of watches. You can see the limit in /proc/sys/fs/inotify/max_user_watches which is usually set to 8192. This means lsyncd cannot watch more than 8192 directories unless you change the kernel setting. Lsyncd itself has no limits.

Reference:
http://code.google.com/p/lsyncd/




blog comments powered by Disqus
Last Updated on Wednesday, 01 September 2010 13:46