lsyncd:是否可以同步列表中的单个文件?

Adi*_*a K 2 rsync synchronization

我想使用 lsyncd 将某些文件从一个 Linux 系统同步到另一个 Linux 系统。这些文件并不局限于一个目录,我也不想要一个目录中的所有文件。

具体来说,我试图确保某些邮件服务器文件与备用服务器保持同步。这是一个列表:

/etc/postfix/master.cf /etc/postfix/main.cf /etc/postfix/blocked_senders /etc/postfix/relay_recipients /etc/mail/spamassassin/local.cf

我可以通过某种列表在单个同步节中指定所有这些文件,还是需要在单独的同步节中配置每个单独的文件?

小智 5

我建议

--[[
The _extra= hack allows synchronization of individual files. Use one sync {}
stanza per source directory. Use additional --include= lines to handle multiple
files within a single source directory.
]]

sync {
  default.rsync,
  delay = 0,
  source = "/etc/postfix/",
  target = "standby.example.com:/etc/postfix/",
  rsync = {
    _extra = {
      "--include=master.cf",
      "--include=main.cf",
      "--include=blocked_senders",
      "--include=relay_recipients",
      "--exclude=*",
    }
  }
}

sync {
  default.rsync,
  delay = 0,
  source = "/etc/mail/spamassassin/",
  target = "standby.example.com:/etc/mail/spamassassin/",
  rsync = {
    _extra = {
      "--include=local.cf",
      "--exclude=*",
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我认为每个源目录都需要一个sync {}节,因为lsyncd通过在目录级别建立的触发器有效地检测更改。