Hardcore Linux

Anything about Ubuntu, Centos, openSuSe and Fedora

DropBox Like using Lsyncd

I have several notebooks that is connected to our File Server via OpenVPN, the problem is sometimes the connection from and to the server is slow and problematic, cannot browse files or takes to long to upload or download things, and the idea of DropBox like application or tool will eventually fix things around those problems.

I found this old link “How to build your own dropbox clone ” (link here) and gives me an idea on howtos.

The key tool is lsyncd (http://lsyncd.googlecode.com)

Lsyncd watches a local directory trees event monitor interface (inotify). It aggregates and combines events for a few seconds and then spawns one (or more) process(es) to synchronize the changes. By default this is rsync. Lsyncd is thus a light-weight live mirror solution that is comparatively easy to install not requiring new filesystems or blockdevices and does not hamper local filesystem performance.

Here’s  the details:

1.  From you current Ubuntu Desktop, install rsync and other necessary packages.

$> apt-get install rsync libxml2-dev build-essential lua5.1

2. Then download the lsyncd souce code and compile.

$> wget http://lsyncd.googlecode.com/files/lsyncd-2.0.4.tar.gz
$> tar xvfz  lsyncd-2.0.4.tar.gz
$> cd lsyncd-2.0.4 $> sudo -s
#> ./configure 
#> make; make install

3. Then create a configuration file in your $HOME/.config/lsyncd path called lsyncd.lua

$> mkdir -p  ~/.config/lsyncd
$> vi ~/.config/lsyncd/lsyncd.lua

4.  The content as follows:

sync{default.rsyncssh, source="/home/username/mybox", host="server.localdomain", targetdir="mybox/", rsyncOps="-ltus"}

5.  Save the file, and before the sync test, make sure you have a passwordless ssh session to the given host, if not, follow this steps:

On your Desktop/client:

$> ssh-keygen -N '' -f  ~/.ssh/id_dsa

On paraphrase prompt, just press ENTER, then the following (note: REMOTE_SERVER is the ssh server host)

$>  cat ~/.ssh/id_rsa.pub | ssh REMOTE_SERVER 'cat - >> ~/.ssh/authorized_keys2' $> ssh REMOTE_SERVER 'chmod 700 .ssh' 

Then have a test

$> ssh REMOTE_SERVER

6. When all are successfully done, create your preferred name for the sync folder, mine.. I just called it “mybox”. It should have the path as follows:

/home/username/mybox
server.mydomain.local:~/mybox

7.  All are set and ready to go, test the lsyncd.

$> lsyncd -nodaemon ~/.config/lsycnd/lsycnd.lua

8. Populate the local folder and watch the remote ssh server for changes.

9. Done.

Note: This is currently a definitely Linux workaround, haven’t tried it in other OS (using cygwin on Windows).

7 responses to “DropBox Like using Lsyncd

  1. fak3r June 18, 2011 at 2:38 pm

    This looks good, be sure to checkout project lipsync, which I developed because of that blog post: http://philcryer.github.com/lipsync/ We’ve fixed many issues recently, and OSX support is being tested/developed now, and yes, cgywin is the way I’d think to look for Windows support (eventually).

    • hardc0l2e June 22, 2011 at 9:15 am

      I having some problem with lipsync. After a restart of the client system, I got this sync problem that when you add items in the client machine, it will be deleted after few moment.

  2. hardc0l2e June 19, 2011 at 7:44 am

    That’s great now with two-way sync. Now I can fully incorporate it in our Samba, FTP server and with this features, you can have an offline version of your files in the server.

    Thanks dude.

  3. hardc0l2e November 8, 2011 at 6:40 pm

    It is two-way, modify either any file on the server or on the client…and it updates the older version of the file.

  4. sizroch January 10, 2012 at 9:37 am

    Thanks for the great explanation, your simple method worked far better for me than the lipsync project (which generated error after error and I gave up on it after nearly two days of haggling). Note, with using your method here, the two-way syncing did not work for me; only changes from the client.

    Someone mentioned that I should try Unison as a means of syncing files like DropBox. Do you have an opinion?

    Thanks again.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: