Mac OS X: Changing Your Short Name Without Breaking Time Machine

Today I got the urge to change my Mac OS X Leopard account short name (home directory) so that I would have less to type in Terminal. Here’s how I changed my short name without breaking my Time Machine backups.

A warning

This guide is meant to serve as a reference to those with systems administration experience, or those with an insatiable thirst for tinkering. There are a lot of things that could go horribly wrong, possibly even making your backups unusable. I make no claims that this method will work and I cannot provide any support.

I have not tested the final Ruby script provided below. It was originally two utility scripts that I wrote while working through things and I combined them for simplicity. Review the code, test, and then try at your own risk.

Prepare Time Machine

When you change your short name your username and possibly group will also change. In this event, Time Machine will start a new backup from scratch. This can be avoided by going through all of the Time Machine backups and performing the following actions:

  1. Change the name of the home directory to your new short name (username)
  2. Update the permissions to your new username and group

First, turn off Time Machine backups and make sure that a backup is not currently in progress. Next, disable ACLs on your Time Machine volume using the following command (making the appropriate substitution for <tm_volume>). Without this step, you will be denied access to the files, even as root.

Next, copy the Ruby script below to a file named change_username_tm.rb and then modify it to suit your changes.

When ready, execute the script in dry-run mode and review everything. When you’re satisfied, set dry_run to false and run as root.

Note: There were a lot of files in Library that would error out when trying to change permissions. Everything seems to work, so I guess I’ll find out for sure the next time I attempt a restore (may that day never come). Worst case scenario, I have to restore my files by hand which is what I’ve been doing for years on Windows.

Finally, re-enable ACLs on the TM volume using the following command.

  • Don’t enable backups yet!

Change your short name

Follow Apple’s new instructions on changing your user short name under Leopard: http://support.apple.com/kb/HT1428

Finish up

Say a little prayer and give Time Machine a try to make sure you can still see all of your backups. If everything seems to be working, go with the hail marry and try running a Time Machine Backup Now (hint: there is an option if you click on the Time Machine status button in your menu bar). If the backup works, then you may be home free and it’s safe to re-enable automatic backups.

Breath a sigh of relief and promise yourself to plan ahead the next time you reinstall Mac OS X.

Your experience

If you have had success following this or another method, let me know by posting a comment! But remember, I can’t provide any serious technical support 😉

8 thoughts on “Mac OS X: Changing Your Short Name Without Breaking Time Machine

  1. @Evan, Thanks for the tip. I find it annoying that this useful command is no longer available when it was just added in 10.4 according to the docs. Then again, it has a very niche use. Everyone who runs into this problem might want to consider filing a Mac OS X bug report. The number of duplicate reports influences how Apple prioritizes, so a certain threshold will have to be met to even get them to consider this issue.

    As an alternative, others might have luck with TinkerTool System Release 2. This would also make for an interesting reimplementation project to be added to MacPorts. But again, pretty small use case.

  2. Doesn’t time machine start from scratch because you change the home folder, not because you change your short name (which you can do wihtout changing the home folder)? I wonder, would it be possible to change the home folder to a directory which is a hardlink to your old home folder. Would that prevent time machine to start a new backup?

    1. @Stefan, The short name should match the home directory name. You might be able to get away with a hard link, but personally I wouldn’t want to because it adds unnecessary clutter.

      1. You are right, and the only reason I would be temped to try the trick with the hard link is to leave the old home folder in place for time machine after a short name change. I just thought, maybe this would convince time machine that these are all actually the same files. But anyway, I forgot that you can’t create a hard link to a folder. Or can you?

  3. @Matt, Great to hear!

    A note to all: Keep in mind that I have not fully tested this. I’ve been blessed with a reliable iMac thus far. However, while I haven’t tried a full restore as part of a reinstall I have restored individual directories and files without any issues.

  4. Thanks a ton! I installed Snow Leopard (clean install) but forgot to use the same username as my Leopard install. I ran your script and now Time Machine is working beautifully again.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.