lsyncd include specific files exclude rest

57 views
Skip to first unread message

Armen Geo

unread,
Aug 23, 2021, 10:52:50 AM8/23/21
to lsyncd

I am using lsyncd version 2.2.2. here is my current code.

settings {

logfile = "/etc/lsyncd.log",

statusFile = "/etc/lsyncd.status",

insist = true,

}

sync {

default.rsyncssh,

source = "/home/abc/public_html/course/testcgi/adminfiles",

host = "xxx.xx.xxx.xxx,

targetdir = "/home/abc/public_html/course/testcgi/adminfiles",

delay = 0,

exclude = { '*' },

rsync = {

perms = true,

owner = true,

}

}

As the code stands above it will and does exclude all files. Now I want to include specific file names. I have tried

include = { '*' }

include-from = { '*' }

but neither is working.

Is this not possible to do?

Thanks.

Armen Geo

unread,
Aug 24, 2021, 12:56:05 PM8/24/21
to lsyncd
Hi Axel,
Help I'm stuck.  Can you give me some feedback here please.

Andrew Fruin

unread,
May 3, 2022, 3:23:58 AMMay 3
to lsyncd
Armen,  a year later...

Assuming version 2.2.X

Do not use the sync { exclude={'*'} ... as it can never be overwritten via an include of any sort.
 Therefore you will also need to remove both the include = and the include-from =  statements.
Instead of using sync { variables use an _extra = { ... definition to modify the rsync { as is demonstrated below...
 sync {
    ...
    rsync {
      binary = "/usr/bin/rsync",
         ...
      _extra = { '--include=filename.ext', '--exclude=*' },
      }
}

Please note:  The include must precede the exclude!

The use of _extra {} is a dirty workaround and should only be used as a last resort.
In my opinion this need is a worthy usage of the feature.
Axel has wisely requested that when we find a need to use the _extra workaround that we submit a feature request.
I will if you will. 
Reply all
Reply to author
Forward
0 new messages