2

I need a good way to sync a directory between my OSX 10.6 laptop and my Ubuntu Desktop. Dropbox would obviously be a great choice, however the directory I need to sync is owned by root on both machines and fixing the permissions would screw up the situation I have going. I was considering just writing my own script using rsync (which would indeed be fun) but I'm wondering if perhaps there is something a bit more robust out there. I've heard of Unison, but I don't know very much about it. Would that be a good option for me, or can you come up with something better? Thanks!

Erreth
  • 71
  • 1
  • 4
  • 1
    RSYNC is very robust, but all by hand. I believe some wrote a GUI app that can manipulate rsync on OSX, google around you'll find it. – SpacemanSpiff Jul 11 '11 at 03:36

3 Answers3

3

two easy answers, (and the same you've already mentioned):

  1. Unison if you want something that 'just works'. Has a nice GUI and you can easily define a task there and call from command line, a script, cron, whatever. I use it to synchronize both my laptop and my wife's with our respective user directories on the desktop. It's really that easy.

  2. rsync if you want to control (almost) every aspect. There's lots of arguments that let you respect, modify or clobber permissions, onwers by number or by name, etc. In fact, there's seldom any need for a complete script; usually you only have to find (by trial and error) the best combination of arguments.

Javier
  • 9,268
  • 2
  • 24
  • 24
1

Quite a nice cross-platform (MacOS, Linux, Win, etc & apps exist for iOS, Android) open-source system that provides for bidirectional synchronised files and directories is SyncThing - it provides for continuous file synchronization between two or more computers in real time.

Pierz
  • 623
  • 8
  • 9
0

Unison is a nice solution if you need to do two-way synchronization, and want to be able to resolve conflicts manually. It keeps a note of what was synchronized last time, so it knows if a file has been changed at both ends.

If you want a purely background solution that happens automatically (eg from cron) and has a pure one-way synchronization, rsync may be better. Unison keeps comprehensive metadata around (in ~/.unison) which you don't need if you're doing one-way synchronization.

The fact that both ends are owned by root complicates things considerably, whether you're using rsync or Unison. You'll need to use sudo on the destination to get write access, but you don't want to be ssh-ing into the source as root. Provided the source is all world-readable, you may be able to do this by running sudo rsync on the destination and giving an explicit non-root user for the source (user@host:...). Note that you can use public-key authentication and set up the authorized_keys file so that only rsync can be used with that key.

In one situation I have solved this by exporting the whole directory with the rsync daemon, thus allowing anonymous access. This circumvents permissions, obviously, but my real need was to produce a specific set of ownerships and permissions at the receiving end, not protect the source end.

Neil Mayhew
  • 121
  • 4