Is it possible to sync just ONE file with lsyncd?
Asked Answered
E

2

7

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?

Exterritorial answered 13/3, 2014 at 10:21 Comment(0)
P
4

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.

Pneumothorax answered 20/4, 2018 at 13:34 Comment(0)
K
1

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
Komsomolsk answered 25/8, 2016 at 12:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.