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 3d0d7e5fb2ce288813306e4d4636395e047a3d