MacOS – Trying to copy files and preserve ownership

filesystemmacos

First I tried cp -Rp to preserve ownership of copies files. That changed the ownership from root:wheel to myuser:staff. So then I tried rsync and ditto. All of these are supposed to preserve the ownership, but they do not. They change it to myuser:staff. All commands used with sudo.

For example:

sudo cp -Rp /sourcefiles/ /destfiles/

What am I missing?

Best Answer

Are you copying to a mounted volume that is on another system? If so, it may be confusing the uid and gid's.

Or are you copying to a NAS which might have an override setting for the ownership of the connected user. For example FreeNAS has options for NFS mounts to Mapall User and Mapall Group, and for AFP mounts to set default file and directory permissions

you can check for uid with something like
dscl . -read /Users/ UniqueID
and check for group id with
cat /etc/groups
or
dscacheutil -q group

Could you try tar'ing up a few files, copying them to the new volume and then untar'ing them and then check the file permissions?