Rsync between Mac and Linux
If you are of the small minority who use Rsync and have Mac and Linux computers you’ll want to read this.
I have Plex running on a Mac along with a second server, connected via IPSEC VPN, running Linux. I have become increasingly annoyed with keeping these two servers in sync with the same data and the manual processes I use vary from operating system to operating system. Over the years I've come up with a few scripts and processes that I use, but ultimately this just needs to be automated to the point that I don't have to worry about it other than the initial download.
My previous Rsync adventures, while somewhat basic in nature were always between two Linux machines, and once configured, I was able to add various functionality that improved my process. However, it turns out the Mac and Linux machines I’m using have different ideas about the character sets their filenames are stored in. A file with an accented character on the Mac is completely different to one that looks the same on the Linux box.
The solution took a while for me to find but it’s very simple. Rsync has an option named --iconv
to convert between character sets!
The solution was embarrassingly simple: Much due to a comment I read when researching the problem, 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 it works like magic!
EDIT: Indeed, sometimes, checking the manual page closely is a good thing to do. Here it is, black on white:
1 2 3 4 5 6 7 8 9 | --iconv=CONVERT_SPEC Rsync can convert filenames between character sets using this option. Using a CONVERT_SPEC of "." tells rsync to look up the default character-set via the locale setting. Alternately, you can fully specify what conversion to do by giving a local and a remote charset separated by a comma in the order --iconv=LOCAL,REMOTE, e.g. --iconv=utf8,iso88591. This order ensures that the option will stay the same whether you're push- ing or pulling files. |