from Hacker News

Show HN: Simple realtime two-way sync with SSH, fswatch and rsync

by headgasket on 3/21/19, 10:39 PM with 35 comments

  • by theamk on 3/22/19, 3:44 AM

    So I was wondering, how do you do two-way sync with inheritly one-way tool like rsync? And turns out you cannot do it, not reliably.

    The way script works, it runs change monitor on both sides; if there is a change on local side, it will do local->remote sync; if there is a change on remote side, it will do remote->local sync.

    This can go wrong in many, many ways. Here is the first example that came to my mind: you started a process on remote machine which creates lots of small files -- maybe extracting an archive, or generating images. So the syncer keeps syncing those files in remote->local direction. Meanwhile, you got bored watching the script and decided to edit some code. POOF! Any edits you make are continuously reverted.

    Oh, and there is no error checking anywhere. Did your network had a hickup? Tough, we will march on anyway. Let's it was not in lines 101 or 104 -- if these commands have transient failures, then your newly made changes would just get reverted.

    If you care about your data, please do not use this. Use anything else -- syncthing, osync, unison were named in this thread, they are all good.

  • by rasengan on 3/21/19, 11:37 PM

    Cool project! Another alternative is to just use unison. Not only is it cross platform for windows, Mac and Linux, but on top of that it “just works”.

    Amazing stuff. Brew, Cygwin and your favorite package managers have it.

  • by senorsmile on 3/22/19, 12:15 AM

    I highly recommend osync(1). It has been around a while and has had quite a few users report bugs. The maintainer is active and very helpful. I've used it for a few years now with great success.

    1: https://github.com/deajan/osync

  • by m-p-3 on 3/22/19, 2:10 AM

    Nice system, but I think I'll stick to Syncthing for the time being.
  • by systemspeed on 3/21/19, 11:55 PM

    These sorts of solutions are always tantalizing, especially when developing on a Mac but deploying on Linux, but the killer feature for such an application would be IDE/ST3/Atom/VSC[/etc...] support. If this sync process could be orchestrated from such a development environment directly, it would avoid many design pitfalls, such as degenerating into rapid fs polling.
  • by orliesaurus on 3/22/19, 12:00 AM

    I use a few rsync scripts and build shortcuts, but gonna try yours honestly!
  • by jasonhansel on 3/22/19, 1:27 AM

    For one-way sync, I'd also suggest: https://axkibe.github.io/lsyncd/
  • by mamcx on 3/22/19, 1:05 AM

    Related, any option to sync files that work from iOS/Android (excluding dropbox, just to make things hard)?
  • by techntoke on 3/22/19, 12:29 AM

    Do you feel that it is production ready and that the sync won't become corrupt? Any plans for Android?
  • by etaioinshrdlu on 3/21/19, 11:10 PM

    I have a few qualms with this app: 1. For a Linux user, you can already build such a system yourself quite trivially by using Dropbox.

    2. It doesn't actually replace Dropbox.

    3. It does not seem very "viral" or income-generating. I know this is premature at this point, but without charging users for the service, is it reasonable to expect to make money off of this?

    (Silly satire.)