How To: Extract & Back Up All Your Text Messages & Picture Messages from Your iPhone to Your Mac

Extract & Back Up All Your Text Messages & Picture Messages from Your iPhone to Your Mac

NSA aside, Apple makes it difficult for users to extract and download text messages from their iPhones onto a computer. For whatever reason (legal, devious, neurotic, etc), we've all found a time where we'd like to save backups of certain meaningful, important, or perhaps incriminating conversations (including all MMS or iMessage pictures and videos).

While there are a handful of third-party applications that can help with this process, the majority of them cost money and implement certain techniques that could be shady (ex: requiring you to upload a full iOS backup to a website).

Now, thanks to chelseybaker, you can easily extract all of the text messages on your iPhone and keep them on your desktop using his open-source Perl script.

If the thought of working with an open source script sounds scary to you, don't worry. I'm no coder and it's pretty easy. Even if you've never seen a line of code in your life, I'll hold your hand through all the steps.

UPDATE: Step 5 has been updated, since many of you were having trouble with the PERL script not running successfully. Thanks to Newell Jones for the tip!

Step 1: Back Up Your iPhone

Using iTunes, back up the iPhone with the conversation(s) you want to download. Just Right-Click on your iPhone in iTunes and click Back Up.

Step 2: Find Backup Folder

Once the backup is done, you'll need to find the folder where the backup was stored. To do this,—

  1. Open Finder
  2. Press and hold the Option key
  3. Click Go on the Menu Bar
  4. Choose Library
  5. Select Application Support < MobileSync < Backup
  6. Right-Click and arrange all of the folders by Date Modified. The most recent one will be your latest iPhone backup.

Step 3: Create an iOSBackup Folder on Your Desktop

Create a folder on your desktop and name it iOSBackup. This is where we're going to save everything to make running the script easy.

Step 4: Make a Copy of Your Backup

Copy the backup folder you found from step 2 into your new iOSBackup folder on your Desktop. This lets us work on it without conflicting with iTunes.

Step 5: Download iOSMessageExport Files

UPDATE: This step has been updated.

Download the iOSMessageExport script from Github (or use this direct link to the iOSMessageExport zip file) and open the zip file. The downloaded script includes the following 6 files:

  1. backup.pl
  2. iOSContacts.pm
  3. iOSMessages.pm
  4. iOSSMSBackup.pm
  5. README.md
  6. style.css

Copy all six files into your iOSBackup folder you created on the desktop during Step 3.

Step 6: Use Terminal to Execute the Script

Now you'll need to open up Terminal (which you can find by hitting Command+Spacebar and typing "Terminal").

Type the following Command to change to your iOSBackup folder:

  • cd ~/Desktop/iOSBackup

Now you'll need to enter one more command to execute the script. Using the command below, replace the "<folder>" part below with the name of your backup folder (the long string of letters and numbers):

perl backup.pl --directory_path <folder>/

Note: Be sure to include the forward slash at the end of it and press enter, as seen below:

After pressing enter, head back to your iOSBackup folder.

Step 7: Open Text Messages

In the iOSBackup folder you created, you will now see an _export folder.

Open it and you'll find folders for all the conversations you've had, each one consisting of HTML files that make up the text messages and images. You'll find multiple HTML files in each folder, as the text messages are grouped by days. Next to certain HTML files you'll see corresponding folders containing any pictures you were sent with that text message.

If you click the HTML file your web browser will open up, showing your text message conversation with pictures included. Note that Emoji will only show up if you open the html files in Safari.

And there you have it. All your raw text message data. Backed up and organized. You can now use spotlight to search them, or make copies of any of the images or videos. If you'd like, you can print-to-PDF to convert them to an easier-to-share format.

Just updated your iPhone? You'll find new emoji, enhanced security, podcast transcripts, Apple Cash virtual numbers, and other useful features. There are even new additions hidden within Safari. Find out what's new and changed on your iPhone with the iOS 17.4 update.

89 Comments

I was searching how to save iPhone text messages to PC and landed here. But unfortunately this tutorial is for Mac users. The app demonstrated in this YouTube video works and save iPhone text messages but it comes with some trial limitations. Can anybody here can help me to save iPhone messages to my windows PC for free? Thanks!

If you are still trying to do this, you will need 'perl', which does not come with MS Windows. Download a copy by going to http://strawberryperl.com/ and installing it. Pick either 64 or 32 bit (you likely have a 64 bit)...if in doubt, just pick the 32 bit version. The rest of the instructions are similar. To get to a terminal in step 6, hit <windows>-r and type cmd and press <enter>

This tutorial is for Mac users so I will follow the instructions posted by you coz I'm on Windows 10 PC.

Update: I followed above instructions but it didn't work on my Windows PC but I did some further Googling and found this guide http://www.easyphonerecovery.com/how-to-backup-save-iphone-text-messages-to-pc-or-mac.html . Finally, I could transfer all the text messages and imessages including attachments to my computer. I didn't try but as per the website description it will work on a Mac too.

Followed very step and got this:

Can't locate DateTime.pm in @INC (@INC contains: /Library/Perl/5.12/darwin-thread-multi-2level /Library/Perl/5.12 /Network/Library/Perl/5.12/darwin-thread-multi-2level /Network/Library/Perl/5.12 /Library/Perl/Updates/5.12.3 /System/Library/Perl/5.12/darwin-thread-multi-2level /System/Library/Perl/5.12 /System/Library/Perl/Extras/5.12/darwin-thread-multi-2level /System/Library/Perl/Extras/5.12 .) at iOSSMSBackup.pm line 8.

BEGIN failed--compilation aborted at iOSSMSBackup.pm line 8.
Compilation failed in require at backup.pl line 7.
BEGIN failed--compilation aborted at backup.pl line 7.

Yeah, I'm getting the same exact error. Bummer.

Looks like you're missing the DateTime Perl Module. Try typing the following in terminal to install it:

  • cpan DateTime

I did that, and I'm still getting this error message

v-string in use/require non-portable at backup.pl line 3.

Can't locate DateTime.pm in @INC (@INC contains: /Library/Perl/Updates/5.10.0 /System/Library/Perl/5.10.0/darwin-thread-multi-2level /System/Library/Perl/5.10.0 /Library/Perl/5.10.0/darwin-thread-multi-2level /Library/Perl/5.10.0 /Network/Library/Perl/5.10.0/darwin-thread-multi-2level /Network/Library/Perl/5.10.0 /Network/Library/Perl /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level /System/Library/Perl/Extras/5.10.0 .) at iOSSMSBackup.pm line 8.

BEGIN failed--compilation aborted at iOSSMSBackup.pm line 8.
Compilation failed in require at backup.pl line 7.
BEGIN failed--compilation aborted at backup.pl line 7.

HELP?? :)

after entering the perl backup command...i get this error mesage in terminal:

DBD::SQLite::db prepare failed: file is encrypted or is not a database at iOSSMSBackup.pm line 68.
DBD::SQLite::db prepare failed: file is encrypted or is not a database at iOSSMSBackup.pm line 68

thoughts?

...never mind the last post...I figured it out. I had the "encrypted" option checked during the first backup.
Make sure that is turned off.
Now it's working fine.

What does that mean where is the "encrypted" option?

great job, well done perl script

After attempting to install the DateTime Pearl Module (apparently unsuccessfully), I am getting this message after trying to complete step 6:

v-string in use/require non-portable at backup.pl line 3.

Can't locate DateTime.pm in @INC (@INC contains: /Library/Perl/Updates/5.10.0 /System/Library/Perl/5.10.0/darwin-thread-multi-2level /System/Library/Perl/5.10.0 /Library/Perl/5.10.0/darwin-thread-multi-2level /Library/Perl/5.10.0 /Network/Library/Perl/5.10.0/darwin-thread-multi-2level /Network/Library/Perl/5.10.0 /Network/Library/Perl /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level /System/Library/Perl/Extras/5.10.0 .) at iOSSMSBackup.pm line 8.

BEGIN failed--compilation aborted at iOSSMSBackup.pm line 8.
Compilation failed in require at backup.pl line 7.
BEGIN failed--compilation aborted at backup.pl line 7.

Help please? I am code illiterate. Just trying to save an important text conversation and this was the easiest method I found.

I also tried cpan DateTime to see if it would work.
After doing all of that, this is what comes up for me too

v-string in use/require non-portable at backup.pl line 3.

Can't locate DateTime.pm in @INC (@INC contains: /Library/Perl/Updates/5.10.0 /System/Library/Perl/5.10.0/darwin-thread-multi-2level /System/Library/Perl/5.10.0 /Library/Perl/5.10.0/darwin-thread-multi-2level /Library/Perl/5.10.0 /Network/Library/Perl/5.10.0/darwin-thread-multi-2level /Network/Library/Perl/5.10.0 /Network/Library/Perl /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level /System/Library/Perl/Extras/5.10.0 .) at iOSSMSBackup.pm line 8.

BEGIN failed--compilation aborted at iOSSMSBackup.pm line 8.
Compilation failed in require at backup.pl line 7.
BEGIN failed--compilation aborted at backup.pl line 7.

I'm trying to save text messages for my residency application, and this is the best solution I've found yet. HELP!! Please :)

I really think this will work for me; however, I get the following error after resolving some other issues already resolved in this forum:

sh-3.2# perl backup.pl --directorypath 54fe0e841c70683cadb130339e63cbfa59980195/

Can't locate iOSMessages.pm in @INC (@INC contains: /Library/Perl/5.12/darwin-thread-multi-2level /Library/Perl/5.12 /Network/Library/Perl/5.12/darwin-thread-multi-2level /Network/Library/Perl/5.12 /Library/Perl/Updates/5.12.3/darwin-thread-multi-2level /Library/Perl/Updates/5.12.3 /System/Library/Perl/5.12/darwin-thread-multi-2level /System/Library/Perl/5.12 /System/Library/Perl/Extras/5.12/darwin-thread-multi-2level /System/Library/Perl/Extras/5.12 .) at iOSSMSBackup.pm line 7.

BEGIN failed--compilation aborted at iOSSMSBackup.pm line 7.
Compilation failed in require at backup.pl line 7.
BEGIN failed--compilation aborted at backup.pl line 7.

Has anyone had this same error and know how to resolve it? I am using a Mac Server with OS 10.7.5

@ Joel,
I am getting the same message back (and this is after installing the DateTime.pm successfully):

Can't locate iOSMessages.pm in @INC (@INC contains: /Library/Perl/5.16/darwin-thread-multi-2level /Library/Perl/5.16 /Network/Library/Perl/5.16/darwin-thread-multi-2level /Network/Library/Perl/5.16 /Library/Perl/Updates/5.16.2 /System/Library/Perl/5.16/darwin-thread-multi-2level /System/Library/Perl/5.16 /System/Library/Perl/Extras/5.16/darwin-thread-multi-2level /System/Library/Perl/Extras/5.16 .) at iOSSMSBackup.pm line 7.

BEGIN failed--compilation aborted at iOSSMSBackup.pm line 7.
Compilation failed in require at backup.pl line 7.
BEGIN failed--compilation aborted at backup.pl line 7.

Can't find iossmsmessages...

How can I view them on a PC?? I don't have 'terminal' and the locations aren't the same on a PC... Help??

I'm getting this:

Can't locate DBI.pm in @INC (@INC contains: /opt/local/lib/perl5/siteperl/5.12.4/darwin-thread-multi-2level /opt/local/lib/perl5/siteperl/5.12.4 /opt/local/lib/perl5/vendorperl/5.12.4/darwin-thread-multi-2level /opt/local/lib/perl5/vendorperl/5.12.4 /opt/local/lib/perl5/5.12.4/darwin-thread-multi-2level /opt/local/lib/perl5/5.12.4 /opt/local/lib/perl5/siteperl /opt/local/lib/perl5/vendorperl .) at iOSSMSBackup.pm line 3.

BEGIN failed--compilation aborted at iOSSMSBackup.pm line 3.
Compilation failed in require at backup.pl line 7.
BEGIN failed--compilation aborted at backup.pl line 7.

What exactly is the DBI.pm? Should I install something else? Any help would be much appreciated. Thank you.

I had the same troubles outlined throughout the thread. The two main hangups seem to be 1.) not going through the full perl install, and 2.) not copying all the Github filz into your iOSBackup folder the tutorial says to pluck 2 of them out, but putting all of them from the Github download allowed the process to go through. Awesome Export!

Thanks for your tip, everything works well now. Credited you in the article!

Article has been updated (Step 5 specifically) and it works perfect now!

I really need this to work and I too had the problem with DateTime. I typed DateTime into the Terminal text line and was asked many questions to which I didn't know the answer. I think if you could help me get past the DateTime error, it would work. Can you help?

Article has been updated (Step 5 specifically) and it works perfect now!

DBD::SQLite::db prepare failed: no such table: handle at iOSMessages.pm line 85.
DBD::SQLite::db prepare failed: no such table: handle at iOSMessages.pm line 85.

Thoughts on what might be causing this error. The query appears to be properly constructed, so I'm thinking the
my $dbh = $self->db;
prior to creating the query has the problem. My IOS version is 5.1.1

iTunes 11.1.5

I am getting the same. Export works fine with my current backups running iOS version 6.1.3, but not working for older versions (probably version 5).

Article has been updated (Step 5 specifically) and it works perfect now!

CHELSEY PLEASE HELP!

I get the below error message...

Can't locate iOSMessages.pm in @INC (@INC contains: iOSMessageExport/ /Library/Perl/5.16/darwin-thread-multi-2level /Library/Perl/5.16 /Network/Library/Perl/5.16/darwin-thread-multi-2level /Network/Library/Perl/5.16 /Library/Perl/Updates/5.16.2 /System/Library/Perl/5.16/darwin-thread-multi-2level /System/Library/Perl/5.16 /System/Library/Perl/Extras/5.16/darwin-thread-multi-2level /System/Library/Perl/Extras/5.16 .) at iOSSMSBackup.pm line 7.

BEGIN failed--compilation aborted at iOSSMSBackup.pm line 7.
Compilation failed in require at backup.pl line 7.
BEGIN failed--compilation aborted at backup.pl line 7.

What is going wrong?

Article has been updated (Step 5 specifically) and it works perfect now!

The same problem:

DBD::SQLite::db prepare failed: no such table: message at iOSMessages.pm line 86.
DBD::SQLite::db prepare failed: no such table: message at iOSMessages.pm line 86.

OS X 10.9.3
iTunes 11.2.2
IOS 7.1.1

Article has been updated (Step 5 specifically) and it works perfect now!

followed the updated step 5 "copying the 6 folders" and still get the:

v-string in use/require non-portable at backup.pl line 3.

Can't locate DateTime.pm in @INC (@INC contains: /Library/Perl/Updates/5.10.0 /System/Library/Perl/5.10.0/darwin-thread-multi-2level /System/Library/Perl/5.10.0 /Library/Perl/5.10.0/darwin-thread-multi-2level /Library/Perl/5.10.0 /Network/Library/Perl/5.10.0/darwin-thread-multi-2level /Network/Library/Perl/5.10.0 /Network/Library/Perl /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level /System/Library/Perl/Extras/5.10.0 .) at iOSSMSBackup.pm line 5.

BEGIN failed--compilation aborted at iOSSMSBackup.pm line 5.
Compilation failed in require at backup.pl line 7.
BEGIN failed--compilation aborted at backup.pl line 7.

Even tried the Cpan datetime solution!

What OS X are you running? Or what other information can you provide that might help us troubleshoot this. With the updated Step 5, I was able to pull the texts without the Cpan datetime solution.

You can combine all the conversations for one person into one file by using command cat .html >output.html !

That is exactly what I would love to do!
How exactly can I do that?
I have several text folders, though I would only like to do that to one.
Can you be more specific? ie: provide actual path for that command?
Thank you very much!

UPDATE:

I think I see what you mean. You are actually saying to edit the "PEARL" script to reflect this action. Sorry, but thanks!

Hi Hannah! Can you please clarify how to combine all conversations for each number into one file per number?

This is the error I'm getting, any ideas:

DBD::SQLite::db prepare failed: no such table: message at iOSMessages.pm line 86.
DBD::SQLite::db prepare failed: no such table: message at iOSMessages.pm line 86

Which iOS version are you running?

Are you still active on this page because I am having problems and haven't seen anyone active with responses in months!

We use the decipher text message software at our small law firm since we are required to save (and print out) sms chats with our clients. Meanwhile, I never knew "option key" + go menu would make that hidden library show up!

https://discussions.apple.com/thread/2742375

Hi Marina, does it support a Windows PC and is it free of cost?

I am getting this when I tried to instal CPAN
Running Build install
make test had returned bad status, won't install without force.

I am desperate for this to work, and I am not super techie, but I know I can do it if I don't hit errors all the time.. HELP ME PLEASE!

Windows Instructions

Great script!! This works great on PC as well. I was using Windows 8.1.

You'll have to install Perl first so that Windows can run Perl scripts. I choose Strawberry Perl and downloaded and installed it with no effort or issues and rebooted just to make sure environment path variables and such were updated.

After that, you can follow the steps above just as they are, with slight variations on Step 2 and Step 6.

---Step 2---

If you don't know where iTunes puts your backup files, you can search for "MobileSync" in Windows Explorer. You'll probably have to set your view options to show hidden folders as it is normally located in a hidden folder under your user directory. For example: C:\Users\<USERNAME>\AppData\Roaming\Apple Computer\MobileSync\Backup

Note1: AppData is the folder that is normally hidden

Note2: C:\Users is the directory on Windows 8 where it stores user information. This folder is different on other versions of Windows.

---Step 6---

On a windows PC you'll use the Command window instead of Terminal. You can get to this in various ways on different versions of windows, but the easiest way is to hold the shift button down while right clicking on the iOSBackup folder you created on the desktop. Then release the shift button and choose "Open Command Window Here" from the context menu that pops up. Once the command window opens, continue with the Step 6 instructions above where it instructs you to type in "perl backup.pl --directory <folder>/"

I didn't run into the DateTime Module issue when using Strawberry Perl, but the zip downloaded as part of this article, includes a README.md file that you can open with NotePad for additional help and suggestions from the author.

Hi, Trying your fix, but I must be missing something. The latest message I am getting is Directory does not exist at iOSSMSBackup.pm line 23. Any guidance you can offer?

Thanks!

Thomas, have you found a solution? I'm having the same problem.

Is there any way to modify the style.css? The colors are a bit hard to read. Or -- what's the best way to export as a .pdf? Thanks so much! This worked like a charm.

Hi - simple question. Can this be used to transfer the messages back into an iPhone?

I'm also having the whole "BEGIN failed--compilation aborted at backup.pl line 7" problem. I'm running iOS 10.6.8. I ran the cpan DateTime as well, with no help. Any solutions?

Im getting the error below:

Andrew-Coxs-MacBook-Pro:iOSBackup theman307$ perl backup.pl --directorypath 5d7ef6802e8467fc9a93a7d5cf01ed6079502973/
v-string in use/require non-portable at backup.pl line 3.

Can't locate DateTime.pm in @INC (@INC contains: /Library/Perl/Updates/5.10.0 /System/Library/Perl/5.10.0/darwin-thread-multi-2level /System/Library/Perl/5.10.0 /Library/Perl/5.10.0/darwin-thread-multi-2level /Library/Perl/5.10.0 /Network/Library/Perl/5.10.0/darwin-thread-multi-2level /Network/Library/Perl/5.10.0 /Network/Library/Perl /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level /System/Library/Perl/Extras/5.10.0 .) at iOSSMSBackup.pm line 5.

BEGIN failed--compilation aborted at iOSSMSBackup.pm line 5.
Compilation failed in require at backup.pl line 7.
BEGIN failed--compilation aborted at backup.pl line 7.
Andrew-Coxs-MacBook-Pro:iOSBackup theman307$

getting the following response in my terminal:

-bash: /: Is a directory

and there is no export file anywhere with my messages...
any ideas??
thanks!

Really smooth process!!! Really great!!!! Thanks!

Mine worked great too. I ended up copying and pasting each of the commands instead of typing it. I wasn't doing something right to begin with, but once I stopped trying to type it myself, problem was solved. I think on the word "perl", it's not an "l", it s a symbol. At least that is how it appeared on my screen.

Jane, I was getting that too. Leave off the <> around the folder name.

I also get the error message "Directory does not exist at iOSSMSBackup.pm line 23".

It took me several tried on both codes to discover not to include the • in the first code and where there should be spaces. It would be good if you could make that more clear. Thanks.

When I copied the Backup folder as instructed, Mac added a space and the word copy. I have both included that and not included that when replacing <folder> with the long string of letters and numbers that constitute the folder name. I have included the forward slash at the end.

Any suggestions for what I might be doing wrong?

Running OS 10.9.4 on a MacBook Pro; iOS 7.1.2
.

I keep getting same error message like others above. Has anyone figured out a solution yet?? I have MacBook Pro Version 10.6.8 Thank you!!!

v-string in use/require non-portable at backup.pl line 3.

Can't locate DateTime.pm in @INC (@INC contains: /Library/Perl/Updates/5.10.0 /System/Library/Perl/5.10.0/darwin-thread-multi-2level /System/Library/Perl/5.10.0 /Library/Perl/5.10.0/darwin-thread-multi-2level /Library/Perl/5.10.0 /Network/Library/Perl/5.10.0/darwin-thread-multi-2level /Network/Library/Perl/5.10.0 /Network/Library/Perl /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level /System/Library/Perl/Extras/5.10.0 .) at iOSSMSBackup.pm line 5.

BEGIN failed--compilation aborted at iOSSMSBackup.pm line 5.
Compilation failed in require at backup.pl line 7.
BEGIN failed--compilation aborted at backup.pl line 7.

Got this error message. Anybody know how to fix it.
Running Mac OS 10.9.4 and iOS 8.0
TisHD:iOSBackup tsongam$ perl backup.pl --directorypath 0d923a396fb6ed08cb8391fb86fb963db2badf7b\
>
DBD::SQLite::db prepare failed: no such table: message at iOSMessages.pm line 86.
DBD::SQLite::db prepare failed: no such table: message at iOSMessages.pm line 86.

Script ran fine and I got a lot of messages exported just as indicated. Many Thanks!! However, for one phone number, the most recent texts were not exported. The export stopped at 4/3/2014. Other numbers did export the most recent texts. Does anyone have any ideas as to why this happened and what Can do about it?

Again, Many thanks.

I am getting "no such table" error for iOS version 7.1.

Can you please help get this script running.

Thanks in Advance.

THANK YOU! I was looking/searching/asking for a simple way to get this accomplished and this worked perfectly!

Hi, I am getting the same error as Jane:

-bash: /: Is a directory

I would appreciate help on this as I need to save my photos and videos from iMessage.

Thank you!

Wow... after looking and downloading 3 different 'free' programs to to this (only to be told I have to pay to actually export a txt file), this was a pinch!

Great step by steps instructions!

Excellent tutorial .. and actually worked for me! .. However, I did not want to store a 2.5GB backup on my Desktop. I heard storing anything big on your desktop slows down your machine (Mac). So, I put the whole thing into the Documents folder and then (because I know nothing of Terminal language) I had to go search for basic commands on how to change that simple line (i.e. cd to Documents not Desktop). I got lucky and found a line of code that worked: cd ~/Documents/iOSBackup

oh .. and one more thing .. the purple background for received messages (and the grey background for sent message) was just too much of an eye-sore .. beside making received messages hard to read .. so, I went into the style sheet to change it. All you have to do is open the file 'style.css' in your export folder (in a plain-text editor) and change the word purple to a different hex color (I chose #FC6). And, since I was already at it, I changed the old-school grey background to white.

(here is the exact code)

.received {background-color: #FC6;}
.sent{background-color: #FFF}

Then save the file and that's it. Easier to read and better for print.

I'm still getting "Can't locate DBI.pm in @INC...".

All 6 files are in the iOSBackup folder; I believed perl is installed. Mac runs OS X 10.10.2. Anyone could shed some light on the mystery?

I am using the new /improved step 5 and still receive this error (not solved by cpan datetime):

perl backup.pl --directorypath 7029be19527662f0ec67d35e320d2a8ebc0883b0/
v-string in use/require non-portable at backup.pl line 3.

Can't locate DateTime.pm in @INC (@INC contains: /Library/Perl/Updates/5.10.0/darwin-thread-multi-2level /Library/Perl/Updates/5.10.0 /System/Library/Perl/5.10.0/darwin-thread-multi-2level /System/Library/Perl/5.10.0 /Library/Perl/5.10.0/darwin-thread-multi-2level /Library/Perl/5.10.0 /Network/Library/Perl/5.10.0/darwin-thread-multi-2level /Network/Library/Perl/5.10.0 /Network/Library/Perl /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level /System/Library/Perl/Extras/5.10.0 .) at iOSSMSBackup.pm line 5.

BEGIN failed--compilation aborted at iOSSMSBackup.pm line 5.
Compilation failed in require at backup.pl line 7.
BEGIN failed--compilation aborted at backup.pl line 7.

I have tried this several times and I keep getting this error. I even backed it up again after turning off the encryption.

DBD::SQLite::db prepare failed: file is encrypted or is not a database at iOSMessages.pm line 86.
DBD::SQLite::db prepare failed: file is encrypted or is not a database at iOSMessages.pm line 86.

I had the same issue, but I unchecked the "Encrypt iPhone Backup" option from iTunes before backing up my phone. Now it works fine :)

Finally after several attempts...Praise God...It worked...I don't know what I did differently but now it works. Thank you so much for this blog!

I got the datetime error and did a command line ppm and clicked on the datetime under the available modules then did an install modules up near the top right, and it solved that problem....but

I am getting Directory does not exist at iOSSMSBackup.pm line 23
I read the readme file that says perform the export PERLLIB=iOSMessageExport/
that only got another error
export is not recognized as an internal or external command
now what do i do? I'm using a laptop pc with windows 8.

Same issue here, If I run perl iOSMessageExport/backup.pl --directorypath9ab23..../ I get the message

does not exist at iOSSMSBackup.pm line 23

but running export PERLLIB=iOSMessageExport/ did not produce any errors.
If I run perl iOSMessageExport/backup.pl --directorypath9ab23..../ , I get the message
Can't open perl script "iOSMessageExport/backup.pl": No such file or directory

Should the statement literally have the text "--directorypath" in it?
I am using "/Desktop/IOS
Backup" in its place.

like this:perl backup.pl --/Desktop/IOSBackup 9ab9cf....ff5b/

and get error
Directory does not exist at iOSSMSBackup.pm line 23.

I backed up the phone to itunes. I didn't do step 2: find the backup folder. The phone is now out of town, away from my computer. Am I able to find the backup folder without the phone attached to my computer? (I don't see a 'find' page.)

I just can't get this to work. Here's the response I get every time:
Mac-002500ef146e:iOSBackup adrefs$ perl backup.pl --directorypath <folder>/2a8516b4c040b8e38004d43b09d2c409cb186630
-bash: folder: No such file or directory
Mac-002500ef146e:iOSBackup adrefs$

Any suggestions?
iPhone 6 running version 8.4
Mac OS 10.10.4

Hello. Could anyone give more detailed instructions for Windows XP or Vista? I'm having problems getting things to work in the command prompt. I've installed Strawberry Perl already, but nothing's working. :'(

Update: I got the script to run. I finally realized I have more than one user on the computer so I had to get to the iOSBackup folder by specifying the user.

Now, I'm getting a similar error to others before me.
DBD::SQLite::db prepare failed: no such table: handle at iOSMessages.pm line 86.
DBD::SQLite::db prepare failed: no such table: handle at iOSMessages.pm line 86.

Did anyone figure this "no such table" error out?

I joined this site just to say HOW INCREDIBLE THIS WORKED!!!! I am so grateful to have figured this out finally. I have been all over the internet and everybody wants money!! Sure you can download the demo, but that doesn't get you anything. The first pass with this I had an error and that was because I had an encrypted backup. Re-did the backup and it worked like a charm. Thanks so much for all the effort put into getting this on the best website and finding it's way to my search query!

Lauri

https://github.com/chelseybaker/iOSMessageExport/issues/13
For all you people like me that were getting the message:
DBD::SQLite::db prepare failed: no such table: message at iOSMessages.pm line 86.

The solution is:
add the *slash* at the end of the 2nd command in terminal.

And please, if you come across this sort of problem, and then get it fixed, tell the rest of the world. You did get this fix for free, and you'd have prob paid money for it.

Still getting that error
Stephens-Air:iosbackup steve$ perl backup.pl --directory_path bakup/
(yes, the folder i have the iphone backup is called backup)

DBD::SQLite::db prepare failed: no such table: message at iOSMessages.pm line 86.
DBD::SQLite::db prepare failed: no such table: message at iOSMessages.pm line 86.

Admittedly, I have rightly been called an "illiterate end-user" but i can't seem to make this system work! I get so far and then - BOOM, the desired result doesn't happen. For instance, early in the process - you say to go to the Finder GO and access Library. There is NO Library on my drop-down menu. Now what do I do?

Apple has hidden the "Library" folder in recent operating system versions. When you select "Go" in Finder hold the option key down and the Library folder will appear with the rest. Once you select it you can treat it like any other folder.

In case anyone lands here looking to run this script and find it not working, here's what I've found.

At some point in the last year or two, it looks like Apple started placing files into subfolders beginning with the first 2 characters of the GUIDs. So, for example, the "3d0d7e5fb2ce288813306e4d4636395e047a3d28" file that the script looks for is now in "3d/3d0d7e5fb2ce288813306e4d4636395e047a3d28".

The script ends up not finding it and failing.

Two solutions:

1) Learn perl and go through and update the script to learn how to navigate the structure.
2) Move all of the files from the subfolders into a single giant folder.

The easiest way to do #2 is to do a search on your iTunes backup folder for ALL files. This should bring up all of the files in all of the subfolders. For me, this was 25k files. Select ALL of these files and move them into a single folder.

Once that's done, you can run this script against the new 1-folder-containing-all-files folder.

For those struggling to extract your files from a Windows 10 machine and receiving the "no such table" error - and don't wish to learn perl as Som SanDiego suggests above - the solution can be found on github under the comments of this file. Here's all you need to do.

  1. Download and install NotePad++ if you don't already have it. This program will display line numbers so you don't have to count.
  2. Open the file "iOSContacts.pm", and add "31/" after the long string on line 16:

contactsdb_filename => '31/31bb7ba8914766d4ba40d6dfb6113c8b614be442',me;

Be sure to save and close the file.

  1. Open the file "iOSMessages.pm", and do two things:

A) Similar to step #2 above, the same thing on line 13 (add "3d/" after the long string)
smsdb_filename => '3d/3d0d7e5fb2ce288813306e4d4636395e047a3d28',

B) add a new line immediately under line 120:
my $sha1filename = substr($sha1filename, 0, 2) . '/' . $sha1_filename;

Save all files, and run the script as the directions indicate. It should work (as of 3/24/2017).

Good luck!

So I know I'm bringing up an older thread, but this has been my goto solution for text and picture extraction for a couple years now. When I use it on a newer back up since one of the more recent updates i'm getting some errors:

Michaels-MacBook-Pro:~ MJohnson$ cd ~/Desktop/iosbackup
Michaels-MacBook-Pro:iosbackup MJohnson$ perl backup.pl --directory_path targetfile/
DBD::SQLite::db prepare failed: no such table: message at iOSMessages.pm line 86.
DBD::SQLite::db prepare failed: no such table: message at iOSMessages.pm line 86.

Not sure what the issue is however any help is very welcome.

To clarify the Windows instructions a bit:
Download and install PERL (default is C:\Strawberry\)
Download the files mentioned in the instructions. Move the .pm files to c:\strawberry\perl\site\lib
Edit the .pm files as per Andrew Ippolito's info above

Follow the instructions in this guide. I have found, however, that while it extracts all the SMS conversation history to HTML files fine, all subdirectories are empty and no attachments get extracted. If anyone has a fix drop a hint!

Hey im getting this error, i am on high sierra

Directory does not exist at iOSSMSBackup.pm line 23

Thank you for this post with terrific directions. I did mess around with it quite a bit with similar errors that other people had. I followed all the links in the comments that related to the errors I was getting but I couldn't get it to work. Through some link in these comments I finally found this page at github: github.com/basnijholt/iOSMessageExport/

It has an updated set of files. When I replaced the ones I had retrieved in Step 5 linked above with the ones in the link I've added here, this process worked like a charm!

So, I think step 5 needs to be updated one more time, if the original author is still around to do that!

Hi Katie, I am having the same issues you were and when I click on the link I do not see updated files to replace the ones I previously downloaded from step 5. Any help on this?

Can anyone tell me why my backup only contains messages from 2016 but photos go all the way back to 2014?

I have followed the edits as listed from 2016-2019, however it does not seem to work anymore. This is the error received:

DBD::SQLite::db prepare failed: malformed database schema (messageidxundeliveredonetooneimessage) - near "where": syntax error at iOSMessages.pm line 86.

DBD::SQLite::db prepare failed: malformed database schema (messageidxundeliveredonetooneimessage) - near "where": syntax error at iOSMessages.pm line 86.

Share Your Thoughts

  • Hot
  • Latest