Joshua Wood

Backup SMS (sms.db) on iOS/iPhone4

Here is a quick little how-to on backing up your SMS database on your iPhone4 or 4.0 firmware 3G/3GS.

First of all, why backup SMS.db by itself when you can backup your entire iPhone? There are many reasons, but the biggest one will probably be so that you can restore your text messages without moving over other potentially unwanted data that comes with restoring your iPhone from a full backup. Personally, I wanted a fresh start when moving from my 3G to my iPhone4 - except I had 2 years of text messages stored on my 3G that I'd rather not lose. Now that the iPhone4 jailbreak has been released, it should be no problem to pull the sms.db from the 3GS filesystem and copy it over to the iPhone4.

The short-version of the process is as follows:

  1. Upgrade to 4.0 (iOS) firmware first, if you're on a 3G/3Gs.
  2. For 3GS and earlier models, jailbreak with redsn0w. You can get the latest here. For iPhone4, simply open jailbreakme.com on your device and follow the instructions.
  3. Install OpenSSH in Cydia.
  4. SSH or SFTP in to your phone using the IP address listed in your Wifi settings. (Port: 22, username: root, password: alpine)
  5. CD to the directory: /private/var/mobile/Library/SMS
  6. Copy sms.db to your local computer

If you have any questions, feel free to use the comments below. If there is enough interest, I'll further explain any of the above steps in case they aren't clear enough.

This is a technique that has been covered by a few other sites for the 3G, and hasn't changed very much with the iPhone4 (Really the only difference that I found is that the path of /var changed to /private/var.) I'll have to do another post on some more creative reasons to get your hands on your SMS.db. If you know your way around SQL Lite (it's easy to learn), there's pretty much no limit to how you can use your iPhone's SMS database!

Update 06/30/10: This post may have been a bit premature since the iPhone4 has not been (officially?) jailbroken yet? I have not gottten around to attempting to restore SMS.db to my iPhone4 (just don’t have the time for it at the moment). If someone can post a solution that would be great, or I will post my findings here once I get around to trying it.

Update 08/04/10: Now that the jailbreak for the iPhone4 has been officially released, you should be good to go!

Comments

I'm Josh Wood, a Rails developer in the Portland, Oregon area. My interests include Ruby best practices, TDD, and cloud architecture. More »