[sf-lug] What's the best way to sync two laptops?

Eric Walstad eric at ericwalstad.com
Wed Nov 30 13:29:40 PST 2011


On Tue, Nov 29, 2011 at 11:19 AM, Rick Moen <rick at linuxmafia.com> wrote:
...
> Possibly of additional interest:
> http://blog.hacker.dk/2008/10/dropbox-is-not-open-source/
> http://fak3r.com/geek/howto-build-your-own-open-source-dropbox-clone/

The fak3r link, above, uses an older, 1.X, version of lsyncd (which
calls rsync to do its transfers).  Here's a recipe that I got working
on my Ubuntu box to implement DropBox-like backups using the version
of lsyncd that comes with the latest version of Ubuntu.  CRUD a file
in the source directory and the changes will propagate to the remote
machine:

Create a DropBox clone with lsyncd

Configure the source machine
sudo apt-get install \
  lsyncd \
  rsync \
  openssh-client

The default config file goes in /etc/lsyncd/lsyncd.conf.lua. You may
have to create that file; it doesn't appear to get created by apt-get
install. Here's an example config file that syncs /path/to/some_dir to
REMOTEHOST:

settings = {
    logfile    = "/tmp/lsyncd.log",
    statusFile = "/tmp/lsyncd.status",
    maxProcesses = 1,
}

sync{
    default.rsyncssh,
    source="/path/to/some_dir",  -- EDIT THIS
    host="USERNAME at REMOTEHOST",  -- THIS
    targetdir="/path/to/backup_dir/some_dir",  -- THIS
    rsyncOps={
        "--links", -- copy symlinks as symlinks
        "--times", -- preserve modification times
        "--update", -- skip files that are newer on the receiver
        -- The -s arg (no space-splitting; wildcard chars only) didn't work for
        -- me.  I got the following error when I include it:
        -- rsync: on remote machine: -sltre.iLsf: unknown option
        -- rsync error: syntax or usage error (code 1) at main.c(1318)
[server=2.6.9]
        "--rsh", -- specify the remote shell to use
        "/usr/bin/ssh -C -p2222", -- AND THIS pass along ssh arguments
here (compress & use port 2222)
    }
}

Test it on the command line in -nodaemon mode:
lsyncd -nodaemon /path/to/lsyncd.conf.lua

Now create/edit a file in your source directory (/path/to/some_dir)
and after a few seconds it should get rsync'd to your remote machine.

Assumes that you have ssh keys set up on the remote machine.

See also:
https://github.com/axkibe/lsyncd/
http://code.google.com/p/lsyncd/wiki/Lsyncd20Manual

hth,
EW

PS, Thanks Rick for pointing out the fak3er link.  I'm looking forward
to using the lsyncd method in the future!




More information about the sf-lug mailing list