lsyncd: Is it possible to sync individual files from a list?
Solution 1
I suggest
--[[
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=*",
}
}
}
I think a sync {} stanza is needed for each source directory because lsyncd detects changes efficiently via triggers established at the directory level.
Solution 2
Though this is an old one I would like put David's response into an "lsyncd" context. A sample configuration could look like this (tested and confirmed on one of my systems):
sync {
default.rsyncssh,
source = "/tmp",
host = "gw2",
targetdir = "/tmp",
delete = false,
rsync = { _extra = { "--files-from=/etc/lsyncd/files.list" } }
}
With the file /etc/lsyncd/files.list containing the files you want to sync with paths relative to "destination" (/tmp here).
Related videos on Youtube
Aditya K
Updated on September 18, 2022Comments
-
Aditya K over 1 year
I want to sync certain files from one linux system to another using lsyncd. The files are not confined to one directory, neither do I want all files from a directory.
Specifically I'm trying to make sure certain mail server files are kept in sync with a standby server. Here is a list:
/etc/postfix/master.cf /etc/postfix/main.cf /etc/postfix/blocked_senders /etc/postfix/relay_recipients /etc/mail/spamassassin/local.cf
Can I specify all these files in a single sync stanza via some kind of list or will I need to configure each individual file in separate sync stanzas?
-
Fox about 7 years@tisc0: Just adding your solution here for informational purposes: _extra = { "--include=php.ini", "--exclude=*" }
-
jack d about 7 yearsActually it's the solution of Marc just above :)