Rsync between Ubuntu and Mac: how to get the iconv option to work
OS X 10.5 has rsync 2.6.9 but the iconv option is only available in rsync 3.x....
To update rsync on your mac you could use macports (installation instructions).
A Macport (and Homebrew) tutorial is available here.
Nick The Swede
Updated on September 18, 2022Comments
-
Nick The Swede over 1 year
I usually backup between two Ubuntu machines, but I now want to use rsync to backup my Ubuntu server with a disk residing on a Mac. But I do not get it to work properly.
The first time all is well, but apparently there is a problem with special characters between the mac and ubuntu 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 how this problem should be solved?
Note, as is perhaps a little hidden in the 'code sample' above, the rsync version on my mac is 2.6.9.
EDIT: Although Jan solved this problem (see my ticked answer), I am still not quite there, since I now receive a new error:
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]
I will make a separate query for this further question, however.
-
Jetson Earth over 9 yearsWhat version of OS X? 10.5 has rsync 2.6.9 but the iconv option is only available in rsync 3.x...
-
Nick The Swede over 9 yearsThanks, that pretty much gives me an answer for why it is not working, although I do not know how to fix it.. yet (while I update programs on my Ubuntu all the time, the thought of using Terminal on my mac for updating shell programs makes me a bit insecure.
-
-
Nick The Swede over 9 yearsThanks, the installation worked perfectly, and now I have rsync 3.1.1 on my Mac. But I still do not get it to work, I am afraid. I get the following error message: 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] -- Can it be that the conversion is not supported on my linux machine, somehow (but I thought the mac now did it, so why does that matter?)?
-
Jetson Earth over 9 yearsDifferent subject, please open another question for that.
-
Nick The Swede over 9 yearsYou are probably right, although my limited knowledge of the inner workings of linux in general makes it hard to tell for me, since my question original is how to get the Linux-Mac rsync to function with special characters. And that full problem is not yet solved. Still, I think it is more instructive to others to divide that (now evidently) complex question into two, and so I will edit my question accordingly and accept this answer, since now accepting the iconv option. I am much obliged, sir: feel free to ponder 'part 2 of my problem as well (soon to be asked).
-
meduz over 8 yearsand then it is important to use the
--rsync-path
option from the NAs to specify the location of the upgraded rsync on the mac...