Search code examples
linuxmacosbashrsync

rsync get from mac to linux: colon replacement


I'm backing up on a linux to rsync data from a remote apple mac to save locally.

linux/mac use "/" or ":" to define path hierarchy, so if mac filenames contain a "/", then rsync replaces the "/" with a ":" to stay safe.

however, sharing/networking this backup back to mac causes troubles this way.

Is there a way I can tell rsync to take another character, ie "_"?

I could rename my files using

find /path/to/basedir/* -iname "*:*"  | tac |  sed 's/\(.*\):\(.*\)$/mv "&" "\1_\2"/' | sh

but this breaks the rsync incremental magic.

Thanks!


Solution

  • It isn't rsync doing the translation; it's done by the kernel and filesystem APIs (see this previous question and the linked USENIX paper). The tricky character appears as a slash in MacOS-heritage APIs, and as a colon in unix-heritage APIs; rsync uses unix-heritage APIs, so it sees a colon.

    The best solution isn't to try to translate the character differently, it's to figure out what's going wrong with the sharing/networking you're using, and figure out why it isn't doing the appropriate translation.