Restore a Corrupted Boot Drive with Time Machine

If your Mac’s boot drive becomes badly corrupted and requires a reformat, one way to recover is to do a full restore from Time Machine. Here’s how my own adventure went, and included, free of charge, are a few hard lessons learned.

______________________

Our family server is a 2009 Mac Pro. It’s a great machine for serving up iTunes content, maintaining our photo archives, and many other things that I keep separate from the iMac I use for scouring the Internet and writing articles. However, last Monday night, disaster struck.

The Crisis

On October 1st, Data Backup 3 informed me that it found an error on the boot drive that needed to be repaired. Disk Utility confirmed:

Unfortunately, it was the kind of error that neither Data Backup 3 nor Apple’s Disk Utility could fix. Disk Utility recommended that I back up my files and reformat the disk. At first, I didn’t think this was going to be a major problem. However, after checking my Time Machine Preferences, I discovered to my horror, that my last TM backup was September 19th. I’d done some important work since then, and so I was starting to get nervous.

After some reflection, I realized what happend. That Mac Pro was the last Mac to get Mountain Lion, and I’d turned off TM on September 19th to do the upgrade. I forgot to turn it back on.

Yes, even the pros hose up once in awhile. No comments. please.

Saving the Day

The boot drive still booted, and the error message suggested that my current files were intact, so I decided to do a Finder copy of all file in my account. There were two reasons for that. First, I had done important work since September 19 that was not in the TM archive. Second, if for some reason the TM restore failed, I’d be up a Jacobian without a Determinant. In other words, screwed.

The nice thing about the Mac Pro is that is has a boatload of drive bays. I keep a 2 TB drive in one of the bays for my iTunes library backup, managed by Data Backup 3, and I also use the remaining 1.5 TB as scratch space, for just such an occasion as this. So I booted from yet a different drive (gotta love those Mac Pro drive bays) and started copying every folder/directory in my account from the corrupted boot drive to the scratch drive.

Armed with the Finder copy backup and a TM machine archive, I felt ready to reformat the boot drive. And I did. Then I realized my mistake.

Each update of OS X wipes out a command line setting to show the user’s Library folder. Sure, you can go to it easily. Sure, you can put it in the Finder side bar. But when it comes to seeing your home directory and doing wholesale Finder copies, out of sight is out of mind. So my current Library folder didn't get saved. Cough.

So here it is again. Do this terminal command after every OS X update. And for reference, here’s Ted Landau's quintessential article on the matter: "How to Permanently Restore the Visibility of Lion's User Library Folder."

(In the shell command below, replace "yourusername" with your account name, minus the quotes.)

chflags nohidden /users/yourusername/library 

This was a more serious mistake because it would likely hose up my iTunes backups of iPhones and iPads and any other important changes to my home Library folder since then. But there was nothing I could do. It was a beginner mistake born of not doing a full recovery very often, but Apple can take part of the blame for being to darned cute.

Yes, even the pros hose up once in awhile. Feel free to unload on me for that one.

Recovery

The next thing I did was to quickly take a look at an article at TMO that has been hugely popular: “Restoring a Full System with Time Machine,” from 2008. Regrettably, times have changed. The article is out of date and linked to a tutorial that no longer exists. 404 error.

So I began the process of reminding myself how to do a full restore from Time Machine.

The first thing I relearned was that if you install a new copy of OS X on the newly partitioned boot drive, then start up, you’ll be offered a chance to restore user files from a Time Machine archive. But here’s the gotcha.

The OS assumes that you have a new Mac or a least a good version of the OS, so all that gets restored is the user accounts and settings. The OS is not overwritten . Worse, I found that some critical settings I had did not not get restored. The restore got graded an “incomplete.” Oops. Think again.

A little more research showed that the right way to do this is to boot from the Lion Recovery partition that’s still on the boot drive, even after you repartition it.

You do that by holding down CMD+R and rebooting. The system still knows which drive to boot from, even if you repartitioned the main part of the drive. That sneaky Recovery partition is still intact. Again, you use Disk Utilities.

This time, when you opt to restore from Time Machine in the Disk Utilities, you’ll get a full restore, OS and everything, from the Time Machine archive. It looks like the shot below. (Note, OS X screen shots are not possible at this stage, so I used my iPhone's camera, probably too close, causing moire patterns.)

Next, you select a source, your connected Time Machine drive, and then select the date of the archive. It looks like this:

Finally, you’ll be asked to select a destination drive for the restoration. Then, you’ll see a progress meter as the complete system restore from the Time Machine archive is reloaded.

Mopping up

The final task was to boot from my emergency drive, as I had done before, and then copy the modified folders where work had been done since September 19 to the boot drive. I renamed several folders, like Documents to Documents-old, then copied over my saved folders from the scratch drive.

At this point, I felt that I had lost zero work and the Mac Pro was back to where it was on October 1st. I updated the boot drive to Mountain Lion (again), patched to 10.8.2, and installed iTunes 10.7. As expected, the fact that the Library folder was out of date created some headaches with iTunes, and that took another hour or so to straighten out. At one point, I was in an endless loop of authorization with the iTunes Store, but I got through it. That’s another story.

Finally, when I was confident all was well, I turned Time Machine back on.

Lessons Learned.

  1. If you turn off Time Machine for any reason, set a Reminder in OS X to turn it back on.
  2. Always explicitly display your Library folder. Always.
  3. Have a very large scratch drive handy for a Finder copy, just in case.
  4. Consider a periodic, second method of redundant backup. For example, Carbon Copy Cloner or Data Backup 3 to an external drive that’s kept safe somewhere else. (I keep mine in a safety deposit box. But my last excursion to the bank was too long ago.) An in-house version, updated every weekend isn’t a bad idea. A 2 TB external drive is not that expensive these days.
  5. Emergency data recovery is seldom done, and each new version of OS X introduces new wrinkles. So, it’s wise to build a full recovery checklist -- or at least bookmark articles like this -- and periodically conduct your own training drill. As they say in Karate class, “You have to die a thousand times in the dojo to live once on the street.”
  6. As in flight operations, a cascade failure of small events leads to a Big, Bad event.

There are some things I could have done differently. I expect to get a lot of flak and advice from all of you. I deserve it this time. So feel free to comment.  At least I don’t trust Time Machine to backup my iTunes library, and I’m pretty good about keeping my Time Machine archive up to date on all household Macs. But...

With just a few cascade errors, you can be cooked.

_______________________

Lightning image credit: Shutterstock