Show HN: Sshync – Auto-sync files over SSH
github.com
github.com
Edit: this one is continuous and rsync is one-shot. Personally, I've been using inotify+rsync+timeout (intofy+rsync has a race condition, so limiting the inotify wait and syncing anyway is essential). Does sshync avoid the race?
Here is a tip on how it can be used ( not tested )
#!/bin/bash
WATCH_PATH="/some/path"
DEST_PATH="/some/path"
REMOTE="root@example.com"
while read LINE; do
FILE=$(echo ${LINE} | cut -d' ' -f2 )
/usr/bin/rsync -r ${FILE} ${REMOTE}:${DEST_PATH}
done < <(/usr/bin/inotifywait -mq -e CLOSE_WRITE --format "%w %f" ${WATCH_PATH})
1 : http://linux.die.net/man/1/inotifywaitAlso, unless you have a very large (breadth or depth) tree, you can just let rsync synchronize the entire path - it is quite efficient, will pick up additional diretories (you need inotifywait -r for that, and AFAIK you still have an unavoidable race).
And what happens to an rsync file that is modified while in the middle of a transfer? [1](I haven't been able to find satisfactory answers to these questions hence the question here).
[1] Say you have a 1,000,000 line file that you are rsynch-ing and you delete line 50000 and insert at line 750000?
Re changing file - IIRC it will keep Resending until file size+mtime at end of transfer is same as in the beginning.
I now use rsync for bidirectional mirroring (any two versions from the last 15 years or so can talk to each other), git for synchronization (getting history for the price of needing to add/commit). Can't beat the network efficiency and compatibility of these two.
Edit: I am now noticing this tool isn't even maintained anymore.
"Rsync is a mirroring tool; Unison is a synchronizer. That is, rsync needs to be told "this replica contains the true versions of all the files; please make the other replica look exactly the same." Unison is capable of recognizing updates in both replicas and deciding which way they should be propagated."
(your profile mentions to respond to one of your comments if someone needs to reach you ...)
http://anonscm.debian.org/cgit/pkg-ssh/openssh.git/tree/cont...
$ rpm -qf /usr/bin/ssh-copy-id
openssh-clients-6.9p1-6.fc22.1.x86_64https://anongit.mindrot.org/openssh.git/tree/contrib/ssh-cop...
This is good to learn!
http://aurelianito.blogspot.com.ar/2014/12/mejorando-el-mirr...
Want to compare any other useless statistics?
I appreciate the positive response, but this is just something I put together quickly and needs a little refurbishing before it can be considered a viable alternative to something like lsyncd.
Top priorities right now are to get rid of ssh-client dependency and to address security concerns. I'd also like to implement file diffing.
Your feedback is invaluable!
This is how I do my email, exim running on a DO instance and I send and receive to my laptop via ssh.
I think newline is valid in filenames in most *nix filesystems, so the possibility to use an alternative RS would be nice.
And fewer features.
(but a cool little project none the less!)
I've found that my file syncing needs tends to be so varied that most of the dedicated tools I've looked at have almost always been just wrong enough not to be worth it compared to just composing something with rsync and inotifywait.
Of course your mileage will vary.
My point was it isn't "hipster" to use something that is fast and efficient.
Glibc is used by multiple packages. I simply identified the number of dependencies to install this tool when nodejs/npm are not installed.
You can use rsync if you like too
> this one is continuous and rsync is one-shot.