axkibe/lsyncd — Issue #113: Other events shouldn't trigger until onStartup is finished
Author: schultzter
Created: 2012-02-18 02:05:54+00:00
State: open

I have a lsyncd config based on the level 3 example in the wiki, with a slight modification:

bash = {
delay = 5,
maxProcesses = 3,
onCreate = "cp -pru ^sourcePathname ^targetPathname",
onModify = "cp -pru ^sourcePathname ^targetPathname",
onDelete = "rm -rf ^targetPathname",
onMove = "mv ^o.targetPathname ^d.targetPathname",
onStartup = [[if [ "$(ls -A ^source)" ]; then cp -pru ^source* ^target; cp -pru ^target* ^source; fi]],
}

In onStartup I copy the files both ways, first source to target and then target to source, so now both directories should be the same (the -p preserves permissions and -u only copies new or newer files).

So when there's a new (or newer) file in the target that I copy to the source it triggers an onCreate (or onModify). But that's redundant.

Maybe there's a better way to do this.

But I think it would be good to have the option to postpone monitoring or to ignore other events until onStartup is completed.