Whether it's for personal or legal reasons, you may want to back up text messages -- both SMS and iMessage. Think about wanting to keep a personal memory of a friend or relative who died suddenly, or the importance of keeping threatening texts from someone, and you'll see why it's important to have a way to do this. Wired's Kif Leswing looked into a few methods for backing up iPhone text messages, and we have a few tips of our own as well.
First, Leswing notes that the SQLite database containing all of those messages is stored on your computer. On a Mac it's in Library > Application Support > Mobile Sync > Backup, in the cryptically-named file 3d0d7e5fb2ce288813306e4d4636395e047a3d28.mddata (to view your Library from the Finder, hold down the Option key while clicking the Go menu -- Library will appear between Home and Computer) . On a Windows PC, you'll find that file in C:\Users\[USERNAME]\AppData\Roaming.
However, you'll need some way of opening the file and parsing the messages hidden within. Leswing suggests Ecamm's PhoneView app (US$29.95) for Mac or CopyTrans (US$19.99) for PC, but if you just want a copy of the file, you know where to find it and can just copy it to an external drive.
This, of course, assumes that you are using iTunes and a USB connection to sync and back up your iPhone, which many people do NOT do. If you're using iCloud for iPhone (or iPad or iPod touch) backup, then you're not going to have access to that file. I also found the text message files in another place on my Mac, and they were much more up-to-date since I do a lot of iMessage chatting on that machine.
Here, I went to Library > Messages and found a completely up-to-date set of three databases: chat.db, chat.db-shm, and chat.db-wal. Those contain all of the messages -- both SMS and iMessages -- and the same folder also contains an Attachments folder that contains hidden treasures. Inside are all of the images and other attachments that were sent to you in those messages, so your cat GIFs are saved for posterity. Once again, you'll need some way of opening the database files to be able to read the messages, although I did notice that just looking at the chat.db file in TextEdit did make it possible to read all of the messages that were buried in a pile of other meaningless garble.
There's one more really easy way for Mac users to back up iMessages. Your Mac should reflect the messages that are sent back and forth from the Messages app on your iOS devices (if not, make sure that you're using the same Apple ID on all devices and the Mac). To create an easy-to-read archive of a string of conversations with your BFF, just launch Messages on your Mac, highlight the person you were texting with, and then bring up File > Print. You'll see both sides of your conversation in the printing thumbnail. Now, click on the PDF button in the lower left of the print dialog (see image below) and save the conversation as a PDF document. You can even add that PDF to iBooks on an OS X Mavericks Mac. (Note that this printout does NOT include delivery times for the messages; that metadata is included in the database files).
Do you have any other hints or tips for Messages backups? Let us all know in the comments.