99.999999% of my readers can probably ignore this one, but if you are of the small minority who use Rsync and have Mac and Linux computers in your home you’ll want to read this.
I have Plex running on a Raspberry Pi for my music. I have a large mp3 folder. Too large to run Syncthing on it unfortunately, but an occasional rsync is perfectly fine.
I thought it worked fine until I quickly realised it was syncing the same files over and over again. It turns out the Mac and Linux machines I’m using have different ideas about 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-8when initialising the rsync from the mac, and always use
--iconv=utf-8,utf-8-macwhen 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:
--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.