Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to sync just ONE file with lsyncd?

Tags:

macos

rsync

sync

I really am stumped - I've spent almost two hours searching for an answer to a ridiculously simple question: how can I continually keep two local files in sync on my mac? I investigated various tricks involving rsync, then settled on using lsyncd.

But for the life of me, I can't figure out how I can get lsyncd to sync two specific files. Is this even supported in the API? It was not clear in the documentation whether or not I could use rsync in this manner; I assume that lsyncd is passing CLI options which are preventing this. My configuration is as follows:

sync = {
    default.rsync,
    source = "/Users/username/Downloads/test1.txt",
    target = "/Users/username/Downloads/test2.txt",
    rsync = {
        binary = "/usr/local/bin/rsync",
        archive = "true"
    }
}

It just says 'nothing to sync'. Help?

like image 512
Steve Benner Avatar asked Mar 13 '14 10:03

Steve Benner


People also ask

Is Lsyncd bidirectional?

Please remember that lsyncd is not primarily designed for a 2-way sync and this is as close as it can get to being one.

How often does Lsyncd run?

Lsyncd monitors files and directories for changes. These changes are observed, aggregated and batched out to the target servers. The default interval for batching is 15 seconds.

Where is Lsyncd config file?

The default configuration file for Lsyncd is created automatically at /etc/lsyncd. conf when the installation is completed. This file contains all the parameters used to perform the synchronization between directories, either locally or remotely.

What is Lsyncd in Linux?

What is lsyncd? lsyncd is a rsync-based tool that monitors specified directories (including subdirectories) for updates and modifications, and then syncs those changes to a specified destination. It is a lightweight command application that is easy to install and configure using the popular Lua language.


2 Answers

This had worked for me:

sync {
    default.rsync,
    source = "/Users/username/Downloads/",
    target = "/Users/username/Downloads/",
    rsync = {
      binary = "/usr/bin/rsync",
      archive = "true",
      _extra = {
        "--include=test1.txt",
        "--exclude=*"
      }
    }
}

You have to use the include/exclude feature of lsyncd, which did not come out of the box. You have to use _extra field to set them.

like image 145
Yeming Huang Avatar answered Nov 03 '22 12:11

Yeming Huang


In lsynd you can do like this

settings {
    logfile = "/var/log/lsyncd.log",
    statusFile = "/var/log/lsyncd-status.log",
    statusInterval = 20,
    nodaemon = true
}
sync {
   default.rsync,
   source="/srcdir/",
   target="/dstdir/",
   rsync = {
     archive = true,
     compress = true,
     whole_file = false,
     _extra = { "--include=asterisk", "--exclude=*" },
     verbose = true
   },
   delay=5,
   log=all,
}

After start lsyncd i have next

root@localhost:/srcdir# ls
12  aster  asterisk

root@localhost:/dstdir# ls
asterisk
like image 38
Retraut Avatar answered Nov 03 '22 11:11

Retraut