How do I copy user home directories from one system to another while preserving all attributes?

I am in the process of dismantling an old macOS High Sierra Server and rebuilding it as a macOS Mojave Server.

I've exported Users and Groups from OpenDirectory on the old one and imported them in the new one.

I could move the user's home folders by shutting the old system down, mounting it in Target Disk Mode on the other and using ditto.

But suppose I do not want that and I want both to keep running (e.g. because the old one is still providing services such as mail and DNS) as the new server is still in buildup and contents on it are experimental (final copy done before going live on the new one). The best way I can come up with that preserves everything is creating a DMG on one system, use ditto there and move that to the other and then do the reverse. Both source and target file system are APFS, a DMG will be HFS+.

Is there a better option that preserves 'everything' from the directories copied? It seems to me that tar and zip don't cover everything. I'm uncertain about rsync/rsync --daemon.


Solution 1:

rsync can do this. I've installed rsync 3.1.3 via MacPorts at both ends, run one end as a daemon, and used -aX as flags.

Solution 2:

Try to ssh into one machine and use cp -avi -p. -i = interactive, -p = preserve directory attributes , -v = verbose. I almost always use cp -avi which preservers structures and attributes of files being copied , with the exception of directory attributes. From man cp

 -p: Cause cp to preserve the following attributes of each source
 file in the copy: modification time, access time, file flags,
 file mode, user ID, and group ID, as allowed by permissions.
 Access Control Lists (ACLs) and Extended Attributes (EAs),
 including resource forks, will also be preserved....

...continued