Macos – Preserve icon with rsync

iconsmacosrsync

I was under the impression from here among other research, that rsync was the command used to sync directories and any contents they have.

I have tried the following commands:

rsync -avzr ~/testing123 ~/Desktop/apartment
sudo rsync -avzr ~/testing123 ~/Desktop/apartment

Neither of them preserve the icon, they both produce the same result:

sent 544 bytes  received 92 bytes  1272.00 bytes/sec
total size is 6148  speedup is 9.67
building file list ... done
created directory /Users/null/Desktop/apartment
testing123/
testing123/.DS_Store
testing123/Icon\#015
testing123/info.txt

sent 566 bytes  received 92 bytes  1316.00 bytes/sec
total size is 6166  speedup is 9.37

They both sync the files correctly but do not preserve the icon from the original file or directory. For directories, rather than preserving the icon on a folder, both commands create a '0 KB' file in the destination directory called 'Icon' with no extension. For files, it does nothing, no mystery 'Icon' file, and no actual icon.

Is it a matter of me using the wrong arguments? What is the problem here? Why won't rsync actually create the same icons on the destination files as on the source files?

Best Answer

You need to specify the -E option to rsync.

   -E, --extended-attributes
          Apple specific option  to  copy  extended  attributes,  resource
          forks,  and  ACLs.   Requires at least Mac OS X 10.4 or suitably
          patched rsync.

Icons are stored in HFS+ resource forks.

Related Question