Skip to content

Instantly share code, notes, and snippets.

@naoaki011
Last active April 14, 2021 01:58
Show Gist options
  • Save naoaki011/d17753576995bcd84ae0d1cd22be6328 to your computer and use it in GitHub Desktop.
Save naoaki011/d17753576995bcd84ae0d1cd22be6328 to your computer and use it in GitHub Desktop.
lsyncd for s3 cli
s3bucket = "public-singleaz-01-5h19ik0zpa42ulxr"
watchpath = "/powercms/data/sites/01/files"
cpexec = function(event)
local src_path = event.sourcePathname
local dst_path = event.sourcePathname
dst_path = string.sub( dst_path , 31 );
spawnShell( event, "aws s3 cp " .. src_path .. " s3://" .. s3bucket .. dst_path .. " --include '*' --exclude '.*' || :" )
end
rmexec = function(event)
local dst_path = event.sourcePathname
dst_path = string.sub( dst_path , 31 );
spawnShell( event, "aws s3 rm s3://" .. s3bucket .. dst_path .. " --include '*' --exclude '.*' || :" )
end
s3_upload = {
maxProcesses = 4,
delay = 0,
onCreate = cpexec,
onModify = cpexec,
onDelete = rmexec
}
settings{
logfile = "/var/log/lsyncd.log",
statusFile = "/var/log/lsyncd.stat",
statusInterval = 1
}
sync {
s3_upload,
source = "/powercms/data/sites/01/files"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment