Database Recovery from an iTunes Backup

We don’t really appreciate the value of a good backup strategy until we really need to rely on it to recover something we’ve lost.

If you’re reading this FAQ, it’s because you’ve lost some or all of your CPT data and didn’t have a dedicated backup of the CPT database on hand. Before you throw in the towel and lose such a valuable part of your chronic pain strategy, let’s try one final approach to see if we can extract a recent copy of your CPT database from a recent iPhone or iPad backup that is stored in iTunes or iCloud.

iTunes & iCloud Backups

We’re going to assume you’re already familiar with the concept of the iTunes/iCloud device backup. As we discuss these backups, we’re going to refer to them as iTunes backups for the sake of brevity, but we’ll clarify if any of our statements are unique to just one of the services.

Normally, you’re going to focus on the iTunes backup as a whole entity. You make a backup of your iPhone and you restore that backup to a new iPhone. Or, you have to reinstall the iOS on your iPad and then you restore your iPad backup on top of it. In both cases, the entire contents of the device is replaced with contents of the backup. The trouble with this approach is that it’s like remodeling your entire house just because you need to change a light bulb. It would be nice if you could just pull the one file out that you need and skip the full restore.

That’s what this set of instructions will guide you through. It will require that you have access to your iTunes backup files, iTunes running on your Mac/PC, and a 3rd party software application that will allow you to browse and extract files from the iTunes backup file structure. More on that last part a bit later.

Identifying a Viable iTunes Backup

First, let’s make sure you have an iTunes backup that we can work with. The perfect situation would be to find an iTunes backup that was created just prior to the point that you lost your CPT data. So before we go through the recovery process, let’s make sure we can find the backup files that we’re going to work with.

◎ Start by connecting your device to iTunes.

  • When you do so, make sure that you stop any automatic iTunes synchronization that might be triggered by connecting to iTunes, because we don’t want to give iTunes any reason to get rid of any of your existing device backups.

◎ Click on the Summary page under the device Settings menu (see A in the graphic below)

  • This page allows you to view information about the backup settings defined for the device. There are two main things you will need to determine.



◎ Determine where your iTunes Backups are being stored.

  • Where are your backups located: locally on your Mac/PC in the form of an iTunes backup OR in “the cloud” as they are when you backup your device directly to iCloud? You can determine this by looking at section B in the graphic and seeing which preference is selected for your device.

◎ Determine which backup set to use.

  • Second, we need to figure out which backup set to use as its possible that iTunes has stored more than one on your device. Looking at area C in the graphic shows information about the timing and location of the most recent backups. In this example, we have a backup from yesterday afternoon sitting in the cloud and one from April 19 locally on this Mac.

Note: If you don’t see any backups listed here for your device, then you won’t be able to proceed with an iTunes backup recovery.

Now, it is possible to have multiple backups of the same device saved on your Mac/PC, so you may also want to open your iTunes Preferences window and select the Devices panel. This will show you a list of the current device backups stored on your Mac/PC and the associated backup dates for each (see graphic below). Again, you’ll need to determine which of these backups will be best suited for recovery of your CPT database.



What’s Inside an iTunes Backup Set?

Let’s assume that you’ve identified a potential target iTunes backup that should hold the CPT database information you need. How do you get at it? If its a local iTunes backup, you might be tempted to just open up a Finder (Mac) or Explorer (Windows) window and start digging through your file system to try and locate the backup files. The problem is that Apple uses a structured method to pack the backups together which makes finding and extracting usable files from them next to impossible without special software.

Here’s an example of what I found when I started looking at the April 19th iTunes backup shown in the previous graphic. As you can see, within a folder named “Backup”, iTunes will store each iTunes Backup set. Each backup set will be named using a unique string of letters and numbers, and within a single subfolder, all the backed up files are stored with coded unique names.


So there really is no way to just go in and grab the one file you need since there’s no easy way to know what you’re looking for. What you need is a dedicated tool that allows you to browse the contents of the iTunes backup. Luckily, there are several free or almost free such packages.

Selecting an iTunes Backup Browser Software Application

◎ If you determined that your iTunes Backup is stored locally on your Mac/PC, then I would recommend using a package called iExplorer.

  • iExplorer will run on a Mac or PC
  • You can download a demo version with limited functionality for free. Luckily for us, that limited functionality is sufficient for our needs.
  • It’s a very powerful tool for managing your iOS devices, so its a tool you may want for the future anyway.

◎ If you determined that your backup set is stored on iCloud, then I would recommend using Phone Rescue

  • Phone Rescue will run on Mac or PC
  • Can recover from both local iTunes backups and remote iCloud backups
  • You can download a demo version, but you have to purchase a $50 license before you can recover any files

These are not the only applications on the market to accomplish this task, so be sure to shop around as features, trial offers and pricing changes often.

The basic operation of each of these packages is similar even if the user interfaces can be quite different. What follows is a walk-through of how you can use the iExplorer application to extract a copy of the CPT database from a local iTunes backup set.

Using iExplorer to Navigate an iTunes Backup

◎ Disconnect your device from your Mac/PC.

  • We won’t need to access your device for these next few steps.

◎ Download iExplorer.

  • iExplorer can be downloaded here.

◎ Install it on your Mac or PC.

  • Installation is quite simple. If you need assistance though, the iExplorer team at Macroplant has a tutorial walkthrough right here that can help.

◎ Launch iExplorer

  • When you first launch iExplorer, you’re going to see a screen similar to the following. For now, you can ignore the buttons referring to buying and registering the software. We’re just going to utilize the demo features.


◎ Go to the File menu and select New Window.

  • You can ignore the request to connect your device since we’re focused on browsing the iTunes Backups only.


◎ Click on the “Browse iTunes Backups” button.

  • This will open a new window showing a list of available iTunes Backups that you can browse. In the example below, we can see the April 19th backup set for the “Kut_iPhone6” device.


◎ Use the left Navigation pane to move to the “Backup Explorer” folder.

  • This folder contains the backed up data for all of the apps on your device, including CPT. You’ll see a number of folders listed in the browser corresponding to each of the apps on the device.


◎ Locate the CPT database file

  • The CPT database file you are looking for is named “CPT_PrimaryDiary.sqlite”. You will find this file within a folder structure similar to the graphic below.
  • If you are using CPT PRO, you need to look in the “App – com.chronicstimulation.paintracker” folder
  • If you are using CPT LITE, you need to look in the “App -com.chronicstimulation.paintrackerlite” folder


◎ Export the database file to your Mac/PC

Once you have selected the database file, click the “Export to Folder” option under the Action menu at the top center of the iExplorer window. Select somewhere on your Mac/PC to temporarily save the database file (eg. your desktop).

◎ Quit the iExplorer app

Complete the Database Restore Process

Now that you have recovered the CPT database file from the iTunes Backup, you can proceed with restoring it to your device. From this point forward, the process is identical to our instructions dealing with an iTunes based Backup/Restore process which we have outlined here.

Just follow the Restore instructions, and make sure you use our new CPT_PrimaryDiary.sqlite file you just saved in the previous steps.