If you’ve ever had to restore an iOS device from its iTunes backup—for example, if you’ve upgraded to a new phone, or if Apple has replaced an iPhone that was having problems—there’s a good chance you’ve come across one of the most frustrating bugs in the iTunes/iOS 4 system: Much of your painstakingly created Home-screen organization is wiped out. Specifically, most of your third-party apps are no longer on the screens where you placed them, and while a few of your folders may remain, even those are missing most of their original contents (which are instead scattered across various screens).

As someone whose job involves quite a bit of app testing and iOS-device restoring, I’ve been hit by this bug more times than I can remember. In my experience, you’re especially likely to experience this bug if your iPhone, iPad, or iPod touch is chock full of apps, but I've seen it happen with devices with only a couple dozen third-party apps. For me, the latest instance happened this weekend, and I decided I was going to figure out if there's a reliable way to preserve app organization when restoring.

The problem

On Friday night, I connected my iPhone 4 to a charger, and when I picked up the phone Saturday morning, all my folders were gone. Somehow, the phone had “reset” its app layout overnight. I have no idea why or how this happened—it’s not a bug I’ve seen, or even heard about, before. The important thing, for the purposes of this exercise, is that I now had several hundred apps randomly scattered across innumerable Home screens instead of neatly arranged, many within folders, across five screens. (Yes, I use a lot of apps, and I download and test a lot of apps. It’s part of my job. That’s my excuse, at least—I may have an app problem.) I wanted my app organization back, and I was hoping a restore could help.

My most-recent iPhone backup was from five days earlier, so I knew things wouldn’t be perfect—I’d done a bunch of on-iPhone app organization during that work week. But that bit of cleanup would be a lot less work than trying to reorganize everything from scratch, either on the phone or from within iTunes. So I connected my iPhone to my Mac, clicked the Restore button in iTunes’ Summary view, and waited for iTunes to wipe the phone and install a new copy of iOS. When prompted, I instructed iTunes to restore the phone’s contents and settings using the most-recent backup.

Once that restore was complete and iTunes started syncing apps and media to the phone, I switched to iTunes’ Apps view…only to find that while iTunes was syncing my hundreds of apps, it wasn’t restoring my folders and app positions.

I remembered being told, a year or so ago, that restoring twice would sometimes restore app organization, and I seemed to remember the process working for me in the past. (I also wondered if this was the iOS equivalent of repairing permissions in Mac OS X—a frequently recommended procedure that rarely solves the problems it’s prescribed for—but I figured it was worth a try.) I stopped the current sync, clicked the Restore button, and waited. When the iOS restore was complete, I chose my most-recent backup for restoring the iPhone's contents.

No dice. I was again left with a mess of apps across innumerable screens. It was a Saturday, and I had stuff to do around the house, so I figured I’d give it another try. And another. And another. And another. I even chose an older backup as the restore source, just in case my most-recent backup was in some way problematic. Nothing worked.

The solution

After seven or eight tries—never let it be said that I’m not persistent—I sat there wondering how Apple could have possibly let this bug exist for so long. Surely there are people working on iTunes and iOS who have enough apps that it’s a massive hassle to reorganize them after a restore? (Or do they all use Spotlight for everything?)

Then I put on my troubleshooting cap and started thinking about why this might be happening—and why sometimes a double-restore works. What if iTunes “restores” your folders before installing your third-party apps? That would mean that when iTunes tries to fill those folders with their original contents, only Apple’s stock apps are actually on the phone. (This would explain why, after an initial restore, the only apps inside folders are the iPhone’s stock apps.) This theory seemed to fit what I was seeing in iTunes during the restore and sync processes. So maybe a second restore would be like giving iTunes a second pass at restoring my folders and app organization?

The problem here is that whenever you click the Restore button in iTunes’ Summary view for your iPhone, iPad, or iPod touch, iTunes wipes your device clean, installs a new copy of the iOS software, and then restores your media and settings from your backup. In other words, you’re forcing a first pass each time.

It turns out that iTunes actually offers two kinds of restores. The first is the one described above, accessed by clicking the Restore button in iTunes’ Summary view for your iOS device. The other one is less obvious—you access it by right-clicking (Control-clicking) your iOS device in iTunes’ sidebar and choosing Restore from Backup. As the dialog that appears explains, the latter procedure restores only your data and settings, not the iPhone’s firmware or OS. What the dialog doesn’t note is that your third-party apps apparently remain on the phone, as well. In other words, it gives iTunes that “second pass” at restoring your Home-screen app organization.

Choosing iTunes' settings-only restore in the sidebar (left); choosing a backup to use for the restore (right)

The trick, of course—and what I neglected to do during all those restores on Saturday—is to let iTunes finish syncing your apps on its first restore/sync. Then you can do the second, non-firmware restore to let iTunes tidy up.

The process

Let’s put this into step-by-step format:

Restore your iPhone, iPad, or iPod touch by connecting it to your Mac, selecting the device in the Devices section of iTunes’ sidebar, switching to iTunes’ Summary view, and then clicking Restore. (If you’ve got a brand-new iPhone, iPad, or iPod touch that you want to set up based on your latest backup, skip to the next step.)

When prompted by the Restore From Backup dialog (which, unless this is a brand-new device, can take ten to 15 minutes), choose your most-recent backup and click Restore.

Wait for the restore process to finish, and then let the phone begin its standard sync process. (If you click the Apps view for your device in iTunes during this sync, chances are you’ll see all of your selected apps strewn across many screens, no longer organized as you had them.)

Once iTunes has finished syncing your apps to the device, you can either click the stop button (the small X) in iTunes’ faux-LCD-display area to stop the sync, or you can let iTunes finish syncing your music, movies, TV shows, and so on. As long as you let iTunes finish syncing your apps, you’re fine—everything else will eventually sync fully.

Right-click (control-click) the device in iTunes’ sidebar, and then choose Restore From Backup from the menu that appears.

In the Restore From Backup dialog, choose the same backup you chose in Step 2; click Restore.

Wait for the sync to finish; if you interrupted the previous sync after only apps were copied, iTunes will first reorganize your apps and then finish syncing all your other media.

I tested this process several times this weekend, and it worked each time. Of course, if you’ve done any additional Home-screen organization since your most-recent iOS backup, you’ll have to repeat those actions—your iPhone, iPad, or iPod touch will be restored to its exact state as of the last backup. So it’s important to make sure your iOS device gets backed up, within iTunes, regularly. And, of course, having to restore twice is a hassle. But until Apple fixes this bug (yes, I do consider it to be a bug—if you restore your hard drive from a backup, you don’t end up with all your files dumped at the root level of your hard drive, right?), it’s a lot less of a hassle than having to reorganize your apps manually, especially if you’ve got more than a few dozen installed.

[After writing this article, Senior editor Dan Frakes wishes iTunes had a Restore Sanity From Backup feature—even if it had to be run twice.]

To comment on this article and other Macworld content, visit our Facebook page or our Twitter feed.