1

I've used lsyncd to sync a local folder to a server I own using rsyncssh with a config file like this:

settings = {
        logfile = "/var/log/lsyncd/lsyncd.log",
        statusFile = "/var/log/lsyncd/lsyncd.status"
}
sync {
        default.rsyncssh,
        source = "/Users/user/source",
        host = "root@xxx.xxx.xxx.xxx",
        targetdir = "/tmp/data",
        rsync = { binary = "/usr/local/bin/rsync" }
} 

Now, I want to perform a "pull" to sync a local directory on another machine (different network) with that remote server.

I'm using this config file:

settings = {...}
sync {
        default.rsync,
        source = "root@xxx.xxx.xxx.xxx:/tmp/data",
        target = "/home/user/dest",
        rsync = { binary = "/usr/local/bin/rsync", _extra = { "-P", "-e", "ssh" } }
}

but I got this error:

Error: failure getting absolute path of [root@xxx.xxx.xxx.xxx:/tmp/data]
Error: Cannot access source directory: root@xxx.xxx.xxx.xxx:/tmp/data

Of course /tmp/data exists, any hint what I'm doing wrong?

Do you know if it is possible to use lsyncd with rsync the way I'm using it to keep a local folder "up-to-date" with a remote source? Or can I use rsyncssh with a remote source?

Thanks!

ams
  • 24,923
  • 4
  • 54
  • 75
dobleseis
  • 629
  • 2
  • 7
  • 12

1 Answers1

2

lsyncd cannot do this because it's not designed this way. It's intended to use inotify events to monitor a directory and then launch rsync to do the heavy lifting. inotify is inherently a local concept, and lsync doesn't actually do any network communications itself.

What you need to do is run an lsyncd service on the server that will launch an rsync configured to connect to your client machine.

That means you'll need to set up an ssh server on your local machine. If your machine doesn't have a suitable domain name/IP address, or is behind a NAT or firewall, then you'll need to set up an ssh -R reverse tunnel and route your server-to-client rsync through that.

Once it's set up it'll work, but honestly, you might find it's easier to use SyncThing.

ams
  • 24,923
  • 4
  • 54
  • 75