Ubuntu – How to synchronize a networked drive and an external drive (Ubuntu & OS X)

filesystemsnetworkingosxrsyncUbuntu

In light of a recent hardware failure, I've decided that it's time to be a little less lax regarding back-ups.

What I have:

  • An Ubuntu 10.10 'server/NAS'
  • A MacBook 5,2
  • A WD external HDD

The server and the MacBook are permanently connected by Ethernet.

I have a directory on the server that I'd like to keep synchronized with the external drive that I plug in from time to time. The Ubuntu filesystem is ext4 and the external drive is HFS+ (Mac OS Extended [Journaled]). It should be noted that this is not case-sensitive. I'm unsure if this is a problem. If it is I can reformat the external HDD so that it is.

It should also be noted that OS X 10.6 ships with a fairly old rsync, ver. 2.6.9. I believe there are some problems with this concerning the handling of resource forks and other things.

So then, what is the best way to proceed?

  • Should I be doing rsyncs across the network? If so some guidance re: how to achieve this using the CLI would be appreciated (I've read the rsync man page numerous times and can't quite get my head around it).
  • Or should I be installing a kernel module so that I can just plug the HFS+ formatted drive into the server and it be read & writeable in Linux? Again, some rsync CLI guidance would be great.
  • Or should I be doing something else entirely?

Cheers.

Best Answer

Yes, rsync is the answer.

Having the drive plugged in locally is going to be a lot faster than the network, but for the purpose of doing backups, I would actually recommend leaving the hardware in place. Do the slower thing and transfer it over the network ... remote to remote if need be, so that you don't break anything by touching it.

There are four main parts to your rsync command. First, the transport mechanism. For local to local transfers this is skipped. If any of the sides are remote, you usually specify a tranfer agent like rsync -e ssh to use SSH transport. After that you specify a source for your files (end with a slash if giving a directory!) and then a target (again end with a slash syncing directories!). So we have rsync -e ssh machine1:/source/folder/ machine2:/source/folder/ so far. Then you can add options like what to skip using --exclude PATTERN, over the wire compression using -z, maybe the -a archive option to handle recursive stuff, matching permissions and such, then -v or --progress if you want to see details or progress as it goes along.

Sample:

rsync -avze ssh ubuntu:/path/to/source/files/ osxhost:/path/to/backup/drive/
Related Question