Database Backup/Restore (via iTunes)

Creating a Database Backup (via iTunes)

One method for backing up your database is to use the iTunes File Sharing feature. Follow these steps periodically to create a backup of your data just in case your device is lost or damaged.

  1. Connect your device to a Mac/PC running iTunes
  2. Click on the device in the left menu tree
  3. Then click on the “Apps” item in the upper menu bar
  4. Scroll down and you’ll see the File Sharing section
  5. Find either the Pain Tracker or Pain Tracker Lite icon (depending on which version you are using)
  6. You should now see the list of files in the app’s documents directory. This will include the database named “CPT_PrimaryDiary.sqlite”. This is the key file that you want to backup. Click on it to select it.
  7. Now click the Save To button and find a suitable storage spot on your Mac/PC.
  8. You’re done!

If you ever need to reload CPT, just reverse the process and copy the database from your Mac/PC back onto your device. Restart CPT and you’ll be back to the point of your backup.

iTunesConnectDevice iTunesFileSharingiTunesFileSelected

Restoring the Database

If you switch devices or have to reinstall the CPT app, you may need to Restore one of your backed up database files (usually the last one you backed up). Doing so is very similar to the above instructions. But first, we need to make sure that CPT is fully closed before changing the database file. So follow these steps:

  1. Tap the device’s Home button to send CPT to the background
  2. Now double tap the device’s Home button to display the background apps bar at the bottom of the screen. You should see the Pain Tracker icon there.
  3. Tap/Hold on the CPT icon until you see the red circle with a “-” (minus sign) in it.
  4. Tap the red circle to fully close the app.

Now navigate through iTunes to the File Sharing screen just as you did during the backup procedure. The difference is that you will choose the “Add..” button in the iTunes File Sharing window.

Select the backup file you want to use and iTunes will copy that database to your device. You should now be able to restart CPT and your data will be restored.