mirror of
https://github.com/octoleo/lsyncd.git
synced 2025-01-07 17:14:03 +00:00
working on excludes
This commit is contained in:
parent
b457351133
commit
f5fc8c3bd2
42
lsyncd.lua
42
lsyncd.lua
@ -1626,17 +1626,13 @@ local Syncs = (function()
|
|||||||
-- Adds a new directory to observe.
|
-- Adds a new directory to observe.
|
||||||
--
|
--
|
||||||
local function add(config)
|
local function add(config)
|
||||||
-----
|
|
||||||
-- Creates a new config table and inherit all keys/values
|
-- Creates a new config table and inherit all keys/values
|
||||||
-- from integer keyed tables
|
-- from integer keyed tables
|
||||||
--
|
|
||||||
local uconfig = config
|
local uconfig = config
|
||||||
config = {}
|
config = {}
|
||||||
inherit(config, uconfig)
|
inherit(config, uconfig)
|
||||||
|
|
||||||
-----
|
|
||||||
-- Lets settings or commandline override delay values.
|
-- Lets settings or commandline override delay values.
|
||||||
--
|
|
||||||
if settings then
|
if settings then
|
||||||
config.delay = settings.delay or config.delay
|
config.delay = settings.delay or config.delay
|
||||||
end
|
end
|
||||||
@ -3075,7 +3071,7 @@ local default_rsync = {
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
-- stores all filters with integer index
|
-- stores all filters with integer index
|
||||||
local filterI = {}
|
local filterI = inlet.getExcludes();
|
||||||
-- stores all filters with path index
|
-- stores all filters with path index
|
||||||
local filterP = {}
|
local filterP = {}
|
||||||
|
|
||||||
@ -3088,7 +3084,7 @@ local default_rsync = {
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
filterP[path]=true
|
filterP[path]=true
|
||||||
table.insert(filterI, path)
|
table.insert(filterI, "+ "..path)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- adds a path to the filter, for rsync this needs
|
-- adds a path to the filter, for rsync this needs
|
||||||
@ -3105,6 +3101,7 @@ local default_rsync = {
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
table.insert(filterI, "- *")
|
||||||
|
|
||||||
local filterS = table.concat(filterI, "\n")
|
local filterS = table.concat(filterI, "\n")
|
||||||
local filter0 = table.concat(filterI, "\000")
|
local filter0 = table.concat(filterI, "\000")
|
||||||
@ -3119,8 +3116,7 @@ local default_rsync = {
|
|||||||
"--delete",
|
"--delete",
|
||||||
"--force",
|
"--force",
|
||||||
"--from0",
|
"--from0",
|
||||||
"--include-from=-",
|
"--exclude-from=-",
|
||||||
"--exclude=*",
|
|
||||||
config.source,
|
config.source,
|
||||||
config.target)
|
config.target)
|
||||||
end,
|
end,
|
||||||
@ -3248,14 +3244,16 @@ local default_rsyncssh = {
|
|||||||
local sPaths = table.concat(paths, "\n")
|
local sPaths = table.concat(paths, "\n")
|
||||||
local zPaths = table.concat(paths, "\000")
|
local zPaths = table.concat(paths, "\000")
|
||||||
log("Normal", "Rsyncing list\n", sPaths)
|
log("Normal", "Rsyncing list\n", sPaths)
|
||||||
spawn(elist, "/usr/bin/rsync",
|
spawn(
|
||||||
|
elist, "/usr/bin/rsync",
|
||||||
"<", zPaths,
|
"<", zPaths,
|
||||||
config.rsyncOps,
|
config.rsyncOps,
|
||||||
"-r",
|
"-r",
|
||||||
"--from0",
|
"--from0",
|
||||||
"--files-from=-",
|
"--files-from=-",
|
||||||
config.source,
|
config.source,
|
||||||
config.host .. ":" .. config.targetdir)
|
config.host .. ":" .. config.targetdir
|
||||||
|
)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
-----
|
-----
|
||||||
@ -3315,24 +3313,40 @@ local default_rsyncssh = {
|
|||||||
if #excludes == 0 then
|
if #excludes == 0 then
|
||||||
log("Normal", "recursive startup rsync: ", config.source,
|
log("Normal", "recursive startup rsync: ", config.source,
|
||||||
" -> ", config.host .. ":" .. config.targetdir)
|
" -> ", config.host .. ":" .. config.targetdir)
|
||||||
spawn(event, "/usr/bin/rsync",
|
spawn(
|
||||||
|
event, "/usr/bin/rsync",
|
||||||
"--delete",
|
"--delete",
|
||||||
"-r",
|
"-r",
|
||||||
config.rsyncOps,
|
config.rsyncOps,
|
||||||
config.source,
|
config.source,
|
||||||
config.host .. ":" .. config.targetdir)
|
config.host .. ":" .. config.targetdir
|
||||||
|
)
|
||||||
else
|
else
|
||||||
local exS = table.concat(excludes, "\n")
|
local exS = table.concat(excludes, "\n")
|
||||||
log("Normal", "recursive startup rsync: ", config.source,
|
log("Normal", "recursive startup rsync: ", config.source,
|
||||||
" -> ", config.host .. ":" .. config.targetdir, " excluding\n")
|
" -> ", config.host .. ":" .. config.targetdir, " excluding\n")
|
||||||
spawn(event, "/usr/bin/rsync",
|
spawn(
|
||||||
|
event, "/usr/bin/rsync",
|
||||||
"<", exS,
|
"<", exS,
|
||||||
"--exclude-from=-",
|
"--exclude-from=-",
|
||||||
"--delete",
|
"--delete",
|
||||||
"-r",
|
"-r",
|
||||||
config.rsyncOps,
|
config.rsyncOps,
|
||||||
config.source,
|
config.source,
|
||||||
config.host .. ":" .. config.targetdir)
|
config.host .. ":" .. config.targetdir
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
-----
|
||||||
|
-- Checks the configuration
|
||||||
|
--
|
||||||
|
prepare = function(config)
|
||||||
|
if not config.host then
|
||||||
|
error("default.rsyncssh needs 'host' configured", 4)
|
||||||
|
end
|
||||||
|
if not config.targetdir then
|
||||||
|
error("default.rsyncssh needs 'targetdir' configured", 4)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
@ -5,6 +5,10 @@
|
|||||||
require("posix")
|
require("posix")
|
||||||
dofile("tests/testlib.lua")
|
dofile("tests/testlib.lua")
|
||||||
|
|
||||||
|
cwriteln("****************************************************************")
|
||||||
|
cwriteln(" Testing default.rsync with random data activity ")
|
||||||
|
cwriteln("****************************************************************")
|
||||||
|
|
||||||
local tdir, srcdir, trgdir = mktemps()
|
local tdir, srcdir, trgdir = mktemps()
|
||||||
|
|
||||||
-- makes some startup data
|
-- makes some startup data
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
require("posix")
|
require("posix")
|
||||||
dofile("tests/testlib.lua")
|
dofile("tests/testlib.lua")
|
||||||
|
|
||||||
|
cwriteln("****************************************************************")
|
||||||
|
cwriteln(" Testing default.rsyncssh with random data activity ")
|
||||||
|
cwriteln("****************************************************************")
|
||||||
|
cwriteln("(This test needs passwordless localhost access of current user)");
|
||||||
|
|
||||||
local tdir, srcdir, trgdir = mktemps()
|
local tdir, srcdir, trgdir = mktemps()
|
||||||
|
|
||||||
-- makes some startup data
|
-- makes some startup data
|
||||||
|
Loading…
Reference in New Issue
Block a user