Terminal command(s) to copy user directory from one system to another

Hello,


I have the directory of "userA" on SystemA and its contents and want to copy it all to "userB" on systemB, while changing all permissions so that "userB" has all the same rights as userA had them on the original system.


I think that rsync would do, but does it automatically assign the user and group rights settings of the user on the target system?


Do I need any special commands? Or just


rsync -avr /Users/userA userB@:destinationHost/Users/userB


Is there anything else to consider, regarding ACLs or so? Thats always confusing me on MacOS ;-)

Or any subfolder of /Users which I better leave out?


Thanks & kind regards,

Olaf.

Mac mini, macOS High Sierra (10.13), Migration from Mac OS El Capitan

Posted on Oct 18, 2018 12:28 AM

Reply
Question marked as Top-ranking reply

Posted on Oct 19, 2018 12:28 AM

Your : was in the wrong place, but you would have figured that out very quickly.


You want the -E option so all the Mac extended attributes and ACLs get copied.


The command given will create /Users/userB/userA/...


You should take a small directory tree and practice on that to make sure you get what you want.


rsync -avr /Users/userA userB@destinationHost:/Users/userB


If you DO NOT have a userA on destinationHost, you could use


rsync -E -avr /Users/userA userB@destinationHost:/Users/


Then on destinationHost, rename userA to userB

sudo mv /Users/userA /Users/userB

You should then spot check your work with

/bin/ls -aleO@ /Users/

/bin/ls -aleO@ /Users/userB/

Against the originals.


If userB already exists, this gets trickier.


You could use the command you specified with the -E, and then try something like

find /Users/userB/userA/ -print0 | xargs -0 -J {} mv {} /Users/userB/

You may have an empty userA directory after you are done. I'm hoping you have a userA directory when you are done.


As I said you should practice with some simiple throwaway directories to make sure you have all the stuff working they way you desire.


Another approach might be to use Carbon Copy Cloner. It can do this, and it is a GUI, and it uses rsync under the covers, and the author contributes to the rsync open sources to keep the Mac bits up to date, and then ships the lastest inside Carbon Copy Cloner. CCC has a 1 month free demo, so you might be able to do everything you need during the demo period.

2 replies
Question marked as Top-ranking reply

Oct 19, 2018 12:28 AM in response to TruFriend

Your : was in the wrong place, but you would have figured that out very quickly.


You want the -E option so all the Mac extended attributes and ACLs get copied.


The command given will create /Users/userB/userA/...


You should take a small directory tree and practice on that to make sure you get what you want.


rsync -avr /Users/userA userB@destinationHost:/Users/userB


If you DO NOT have a userA on destinationHost, you could use


rsync -E -avr /Users/userA userB@destinationHost:/Users/


Then on destinationHost, rename userA to userB

sudo mv /Users/userA /Users/userB

You should then spot check your work with

/bin/ls -aleO@ /Users/

/bin/ls -aleO@ /Users/userB/

Against the originals.


If userB already exists, this gets trickier.


You could use the command you specified with the -E, and then try something like

find /Users/userB/userA/ -print0 | xargs -0 -J {} mv {} /Users/userB/

You may have an empty userA directory after you are done. I'm hoping you have a userA directory when you are done.


As I said you should practice with some simiple throwaway directories to make sure you have all the stuff working they way you desire.


Another approach might be to use Carbon Copy Cloner. It can do this, and it is a GUI, and it uses rsync under the covers, and the author contributes to the rsync open sources to keep the Mac bits up to date, and then ships the lastest inside Carbon Copy Cloner. CCC has a 1 month free demo, so you might be able to do everything you need during the demo period.

Oct 19, 2018 12:34 AM in response to BobHarris

Hi Bob,


before I read your reponse, I actually used


rsync -avr /Users/userA/ --exclude 'Library' --exclude '.*' userB@target.host.de:/Users/userB/


And yes, I got the error message about placing ":" wrongly, but corrected it.


So maybe I let the command run again with the "-E" option?


But right now, it seems I can access all files thus copied ... with my userB.


I do have a licensed copy of CCC, thanks for pointing to that tool as well!


Regards,

Olaf.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Terminal command(s) to copy user directory from one system to another

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.