I really am stumped - I've spent almost two hours searching for an answer to a ridiculously simple question: how can I continually keep two local files in sync on my mac? I investigated various tricks involving rsync
, then settled on using lsyncd
.
But for the life of me, I can't figure out how I can get lsyncd
to sync two specific files. Is this even supported in the API? It was not clear in the documentation whether or not I could use rsync
in this manner; I assume that lsyncd
is passing CLI options which are preventing this. My configuration is as follows:
sync = {
default.rsync,
source = "/Users/username/Downloads/test1.txt",
target = "/Users/username/Downloads/test2.txt",
rsync = {
binary = "/usr/local/bin/rsync",
archive = "true"
}
}
It just says 'nothing to sync'. Help?
Please remember that lsyncd is not primarily designed for a 2-way sync and this is as close as it can get to being one.
Lsyncd monitors files and directories for changes. These changes are observed, aggregated and batched out to the target servers. The default interval for batching is 15 seconds.
The default configuration file for Lsyncd is created automatically at /etc/lsyncd. conf when the installation is completed. This file contains all the parameters used to perform the synchronization between directories, either locally or remotely.
What is lsyncd? lsyncd is a rsync-based tool that monitors specified directories (including subdirectories) for updates and modifications, and then syncs those changes to a specified destination. It is a lightweight command application that is easy to install and configure using the popular Lua language.
This had worked for me:
sync {
default.rsync,
source = "/Users/username/Downloads/",
target = "/Users/username/Downloads/",
rsync = {
binary = "/usr/bin/rsync",
archive = "true",
_extra = {
"--include=test1.txt",
"--exclude=*"
}
}
}
You have to use the include/exclude feature of lsyncd, which did not come out of the box. You have to use _extra field to set them.
In lsynd you can do like this
settings {
logfile = "/var/log/lsyncd.log",
statusFile = "/var/log/lsyncd-status.log",
statusInterval = 20,
nodaemon = true
}
sync {
default.rsync,
source="/srcdir/",
target="/dstdir/",
rsync = {
archive = true,
compress = true,
whole_file = false,
_extra = { "--include=asterisk", "--exclude=*" },
verbose = true
},
delay=5,
log=all,
}
After start lsyncd i have next
root@localhost:/srcdir# ls
12 aster asterisk
root@localhost:/dstdir# ls
asterisk
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With