mac migration 04 – actually migrating user data using rsync

This is the fourth article in my Mac Migration series that deals with automatically (or least very minimally manually) migrating a user from one Mac to another Mac. So far we have covered how to list printers on the old Mac, list all non-user files and folders on the old mac, and list all non-core (this can vary from company to company) applications on the old Mac – and then transfer them to the new. This article will deal with actually migrating the users’ data from one computer to the next.

Since we are not concerned about system or application data, we only need to worry about user data, and non-user, non-system data. If you have a known user-writeable space, even better as this makes data transfer that much more straightforward. I prefer to use rsync over other data copy methods since it preserves resource forks and file/folder permissions (cp does not) and tends to be faster than other methods (ditto). The code I use to transfer user data follows:

rsync -avE --exclude=*Caches* /Volumes/Work\ 1/Users/"$ConvertedName" /Volumes/Work/Users/
rsync -avE /Volumes/Work\ 1/Users/Shared /Volumes/Work\ 1/Users/
rsync -avE --exclude=*Users* /Volumes/Work\ 1/ /Volumes/Work

The three rsync commands above will successfully sync all user data pertaining to the given username ($ConvertedName), all non-user data in the user-writeable filespace, and ignore any user caches, as I’ve found that moving cache files between different hardware models and operating systems can create headaches.

The -a option specifies archive mode, essentially make an exact replica of the source on the target. This includes recursing into directories it finds to copy the data there, copying any sym links, and preserving permissions. The -v option specifies for rsync to be verbose, that is, write the result of every copy and other overhead commands to stdout. Finally, -E specifies to copy extended attributes (resource forks), if found. A lot of older and poorly written applications still create resource forks, so to preserve as much data and metadata as possible (and to avoid angry user phone calls) we specify to copy all resource forks.

Since rsync is a unix command, it follows unix filesystem rules and naming conventions. Since OS X pretty much lets your users name files whatever they want, this can sometimes get tricky in that if rsync encounters a file that breaks unix naming restrictions, it will simply not copy that file. If that file happens to be a directory it will skip that directory entirely and move on to the next valid name. These skips will not show as errors so it’s entirely possible to have a 400GB rsync complete “successfully” in under an hour, having only copied 60GB. A favorite character to look out for is the “ƒ” that is so often added to folder names by various apps. A nice way to test whether rsync actually failed to copy data or just skipped an illegal name is to perform a drag and drop copy in OS X. Since this copy is overseen by OS X, it will follow OS X naming rules, and will most likely succeed.

About this entry