I'm trying to watch a folder, and its subfolders for any changes in the files (HTML/CSS/JS/Etc). Once a file has changed, I want to upload it to a mounted drive from a remote server. Currently, I am using this in terminal:
fswatch -o ~/Desktop/Site/ | xargs -n1 sh ~/Documents/App\ Syncs/rsync_files.sh
rsync_files.sh:
rsync -rvzut --info=progress2 --delete-after --delete-excluded --exclude-from=/Users/ME/Documents/App\ Syncs/exclude_list.txt /Users/ME/Desktop/Site/ /Volumes/devroot$/Site;
The thought is that the fswatch will call the rsync each time there is a change in the file structure. It works, but it is VERY slow, esp over a crappy connection.
My question is, am I doing this right or is there a better solution for what I'm trying to accomplish? Can my rsync command be better optimized? Is there an app already made that will do this very thing for me?
Basically I want to mimic the file panel in Dreamweaver 2014 without having to use Dreamweaver. My setup is Sublime Text 3 and Codekit 2.
I guess it depends on where the bottleneck is, which is not clear in your question. One thing though: if the connection is "crappy", I'd worry about fixing the connection before trying to tune rsync
.
As far as fswatch
is concerned, you are already using -o
, so I devise no further way to improve its performance. Maybe I would increase the latency value (-l
): the command in your question will output events with a maximum frequency of 1 second. Tune it to a higher value: start with a value on the same order of magnitude of the amount of time taken by the synchronisation job to finish.
As far as rsync
is concerned, you may find room for some improvement. Start asking yourself the following questions (and then google about it):
rsync
the best option?-W
) make sense?-z
) make sense?--inplace
) make sense?If your connection is slow, start using -z
and --inplace
and see whether rsync
performance improves.