Web-server – Lsyncd exclude files or folders not working

lsyncdrsyncsynchronizationweb-server

I am using lsyncd for live syncing between master and slave and I want to exclude files like .htaccess and git files to slave server. I have configured like this:

sync
{

default.rsync,

source="/home/test/",

target="202.63.240.146:/home/test",

excludeFrom="/home/test/public_html/.htaccess",

rsync={archive = true, perms = true, owner = true, _extra = {"-a"}, rsh ="/usr/bin/ssh -l root -i /root/.ssh/id_rsa",}

}

But seems it's not working. Can anyone please correct my configuration. My lsyncd version is 2.2.

Best Answer

Your excludeFrom= needs to be a file containing a simple list of files/directories to exclude. You appear to want to exclude the .htaccess file(s), in which case you'd want exclude = { '.htaccess' }. Refer to the 'Exclusions' section in the lsyncd manual.

Incidentally, your _extra={'-a'} may not be want you want. -a is equivalent to -rlptgoD (see rsync manpage). The lsyncd defaults for those options are

  • [-r] recurse = true
  • [-l] links = true
  • [-t] times = true
  • [-p] perms = false
  • [-g] group = false
  • [-o] owner = false
  • [-D/--devices] <= not supported by lsyncd

Since you already override perms/group/owner, your -a is effectively equivalent to --device. [=recreate character and block devices at destination]

Related Topic