4

I have a problem with using rsync for backuping files on my remote linux machine to my Mac. The first time all is well, but apparently there is a problem with special characters between the mac and linux machine, since every time I run the rsync operation after that, the files with special characters are first deleted and then re-synced. It seems as if there is a problem with different character sets.

The preferred solution seems to be to use the --iconv option:

You can use rsync's --iconv option to convert between UTF-8 NFC & NFD, at least if you're on a Mac. There is a special utf-8-mac character set that stands for UTF-8 NFD. So to copy files from your Mac to your NAS, you'd need to run something like:

rsync -a --iconv=utf-8-mac,utf-8 localdir/ mynas:remotedir/

This will convert all the local filenames from UTF-8 NFD to UTF-8 NFC on the remote server. The files' contents won't be affected.

That sounds all and well, but my mac does not seem to recognise that option, since I get:

>     MyMachine:~ Macuser$ /usr/bin/rsync -av --delete --iconv=utf-8,utf-8-mac user@linuxmachine:/home/linuxuser/Test/ /Users/Macuser/Test/
>     rsync: --iconv=utf-8,utf-8-mac: unknown option
>     rsync error: syntax or usage error (code 1) at /SourceCache/rsync/rsync-42/rsync/main.c(1333) [client=2.6.9]

Any suggestions on what to do?

EDIT: the rsync version on my mac is 2.6.9.

Macuser$ rsync --version
rsync  version 2.6.9  protocol version 29

If that version does not support the --iconv option, how do I update in a safe manner?

EDIT: I finally figured out that apart from updating rsync, I also had to switch the order in which I specified the character sets, so I added an answer below.

  • What version of rsync do you have – Mark Oct 8 '14 at 11:14
  • 2.6.9. -- see edit. – Nick The Swede Oct 8 '14 at 11:25
6

I finally figured out that apart from updating rsync, I also had to switch the order in which I specified the character sets: I thought you were supposed to specify the character set in the order of transformation; but it seems as that is not the correct syntax. Rather, one should always use --iconv=utf-8-mac,utf-8 when initialising the rsync from the mac, and always use --iconv=utf-8,utf-8-mac when initialising the rsync from the linux machine, no matter if I want to sync files from the mac or linux machine.

Then @Mark's solution works like magic!

3

The --iconv argument was added in rsync version 3.0.0 (release notes) OSX provides only version 2.6.9 (see Apple's open source page)

Thus you need to get a newer version of rsync. The latest is 3.1.2 (2.6.9 was released in 2006)

I would also get a newer version rsync as xattr copying was also introduced after 2.6.9

I think the simplest way to get a new rsync is to install a package manager like Macports or Homebrew and then install rsync or you can install from the source

  • Thanks! I now have 3.1.1 on my Mac, but I still get an error message i am afraid: iconv_open("UTF-8", "utf-8-mac") failed rsync error: requested action not supported (code 4) at rsync.c(118) [sender=3.0.9] rsync: connection unexpectedly closed (0 bytes received so far) [Receiver] rsync error: error in rsync protocol data stream (code 12) at io.c(226) [Receiver=3.1.1] -- there are different version on remote and local machine, obviously, but since they are both above 3.0.0, why does that matter? – Nick The Swede Oct 8 '14 at 12:06
  • Sorry I don't know more I would create a new question - probably on SuperUser as I suspect a non OSX specific issue – Mark Oct 8 '14 at 12:11
  • Will do - thanks a bunch for taking me a long way in the right direction, in any case! – Nick The Swede Oct 8 '14 at 12:28
  • I turns out that apart from having the wrong version of rsync on the mac (which your rsync update fixed), the problem was that I thought you were supposed to specify the character set in the order of transformation; but it seems as that is not the correct syntax. Rather, one should always use --iconv=utf-8-mac,utf-8 when initialising the rsync from the mac, and always use --iconv=utf-8,utf-8-mac when initialising the rsync from the linux machine, no matter if I want to sync files from the mac or linux machine. When used in that order, all was fine. Then it works like magic! – Nick The Swede Nov 20 '14 at 18:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .