OneDrive Blocks Copying User Profiles
The concept of user profiles on the Mac has always been very simple:
- A user is defined in a record in the Mac’s local directory. This record contains the user’s account name, id number, home directory and other basic information. It’s the counterpart of what would be in
/etc/passwd
in Linux. - All the user’s data is stored in their home folder (in
/Users/username
).
Unlike Windows, there are no registry hives or similar concepts that are permanently mounted either. This makes it easy to transfer or archive user profiles. In the past, I’ve often used rsync
(or even tar
) to transfer user profiles between Macs. This method is often more straightforward than using migration assistant, if you know what you’re doing. Transferring a profile via rsync could be done directly between SSH- and root-enabled Macs via a simple command like:
rsync -aHvE /Users/username root@newmac:/Users
If the user has a different numerical user id on the target mac, you would need to adjust that in the user settings or use chown
, but other than that, transferring profiles is really simple.
However, ever since Microsoft adapted OneDrive to Apple’s new File Provider API, this command often hangs when trying to copy files stored in a OneDrive folder. This probably happens because not all OneDrive files are actually downloaded. Most files will be stubs, that when opened trigger OneDrive to download the full file. Of course that doesn’t work when OneDrive isn’t running, or in cases where we’re copying the user profile via Target Disk. It would be nice if rsync could simply copy the stubs, but alas, it just hangs, waiting forever for data that will never download.
In all fairness, I’m not entirely sure if Microsoft is at fault here. It could very well also be an issue with Apple File Provider API, that possibly also affects iCloud documents. But if you look behind the curtain at how OneDrive handles files I wouldn’t be surprised if this is because of an implementation detail in OneDrive itself.
In any case, to avoid hangs when copying user profiles around, it’s now best to exclude the CloudStorage directory, like so:
rsync -aHvE --exclude "/Users/username/Library/Cloudstorage/*" /Users/username root@newmac:/Users
This way you’ll skip copying files that make use of the File Provider API, so the copy doesn’t get stuck. Granted, you’ll be missing some files on the target device, but you should be able to download those again from e.g. OneDrive.