SMS messages on the iPhone are stored in a SQLite database, and if you need to back up your messages you can do so using one of the methods below.

Firstly you’ll need to Jailbreak your iPhone so you can get remote access to it via SSH. Download and use PwnageTool as per these instructions to Jailbreak the iPhone, then open Cydia and install the OpenSSH package if it hasn’t been installed already.

Launch the Settings app on the iPhone, choose “Wi-Fi“, then turn “Wi-Fi” on and connect the iPhone to your Wi-Fi network (or create a Wi-Fi network on your Mac by clicking the Airport icon in the menubar and choosing “Create Network…“, then connect the iPhone to that).

After the device connects to the network, tap the blue right-pointing arrow next to your Wi-Fi network entry in the Settings app and make a note of the iPhone’s IP Address on the network.

iphone-sms-settings-wifi

Open a new Terminal window on your Mac, then enter this command to copy the iPhone’s SMS Database file to your Desktop (replace “{IP_ADDRESS}” with the IP Address you noted above):

scp root@{IP_ADDRESS}:/var/mobile/Library/SMS/sms.db ~/Desktop/

When you enter the scp command you will be prompted for a password, simply enter the default iPhone root password (alpine).

Exporting the iPhone SMS Database to a CSV file using the command line:

Open a new Terminal window, then enter these commands (assuming that the SMS Database file is stored on your Desktop and that you want to export the SMS messages to a file named “output.csv):

cd ~/Desktop
sqlite3 -csv -separator ',' sms.db "select * from message;" > output.csv

Exporting the iPhone SMS Database to a CSV file using a GUI tool:

The GUI Tool used in this example is called SQLite Database Browser and can be downloaded from here.

iphone-sms-sqlite-database-browser

Download and install the application, then run it. Click the “File” menu, then choose “Open Database“. Choose your SMS Database file and click the “Open” button, then switch to the “Browse Data” tab. Choose the “message” table, then click the “File” menu and choose “Export“, “Table as CSV File“. Choose the “message” table and click the “Export” button, then choose a location to save the file to.

Explanation of fields:

The iPhone SMS Database’s “message” table contains several fields of which the most relevant ones are:

rowid: A unique identifier for each message
address: The telephone number of the sender / recipient
date: The Unix Timestamp of when the message was sent / received
text: The message content
flags: 3 Indicates that the message was sent, 2 indicates that it was received
group_id: Indicates the conversation the message belongs to (messages are linked together via groups and the group_member table).

Share this article: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Twitter
  • GatorPeeps
  • Digg
  • Reddit
  • muti.co.za
  • DZone
  • del.icio.us
  • StumbleUpon
  • Technorati
  • Ma.gnolia
  • Slashdot

Related posts:

  1. Backup your iPhone’s Voicemail Messages
  2. Enabling remote access to a MySQL Database Server
  3. Configure Gmail IMAP accounts properly in Apple Mail and on the iPhone
  4. Jailbreaking, Activating and Unlocking my first-generation iPhone from firmware 2.2 to 3.0
  5. Enable Emoji Characters on iPhones outside of Japan