A colleague of mine recently asked if I knew of any applications that would allow him to save and backup voicemail off his iPhone. He had found The Missing Sync, but frankly $40 is a bit steep just to save voicemail; he didn't need to do anything else.
A quick search turned up an article describing how to save voicemail from a jailbroken iPhone, but nothing so simple for a non-jailbroken phone. The article did, however, drop a clue: voicemails are stored in AMR format.
iPhone backup files are conveniently all stored in a directory named for the phone's ID in "~/Library/Application Support/MobileSync/Backup/". The files all have a .mddata or .mdinfo extension. Could any of them contain an AMR file? According to the AMR format RFC, plain, single-channel AMR files should start with the ASCII string "#!AMR\n". A simple grep revealed that several files in fact contained the AMR header. As it turns out, Apple has politely stored each voicemail in its own, separate file – no file carving is necessary to extract the voicemail.
It's so simple to find the voicemail in an iPhone backup, it can be done with a bash shell one-liner (credit to Seren in the comments for finding a slightly more compatible "find" syntax):
pushd ~/Library/Application\ Support/MobileSync/Backup ; for I in `find . -name *.mddata -exec grep -la '#\!AMR' {} \;` ; do cp $I $OLDPWD/`basename -s mddata $I`amr ; done ; popd
That'll copy all the voicemail for the current user's iPhone(s) to the current directory, named with a .amr extension. (Both QuickTime and iTunes can play .amr files.) Note that this can take a minute or two – so be patient for at least a couple minutes if it looks like nothing is happening.
For those less familiar with bash, I'll break down the one-liner a bit:
pushd ~/Library/Application\ Support/MobileSync/Backup ; \<br />
for I in `find . -name *.mddata -exec grep -la '#\!AMR' {} \;` ; \<br />
do cp $I $OLDPWD/`basename -s mddata $I`amr ; \<br />
done ; \<br />
popd
1. pushd changes the current directory and stores the previous current directory in the $OLDPWD environment variable. The "Application Support" directory has an unfortunate space in it, which makes it a bit tougher to throw around pathnames using it without getting the escaping just right – I didn't want to bother with it.
2. The find command looks for only those files that end in .mddata to save a small amount of time (there are no voicemails in .mdinfo files) and then passes each to grep. grep is used to look for files with the AMR header; the -la options are used to quit looking through a file after the first match (again, this is for a small speed improvement – the AMR header ends with a newline and must be the first thing in an AMR file, which means grep is able to move on quicker on the few files that match) and to treat files as text.
3. Use basename to strip off the .mddata filename extension so we can make a copy of the .mddata file with a .amr extension.
4. End of loop.
5. popd restores the current directory to the original working directory.
There are tons of different ways of doing the same thing; I tried for a little while to find one that was functionally equivalent (using xargs rather than a for-loop and bash substring manipulation rather than basename, etc.) but would fit in a Twitter update, but alas, I'm not a bash expert, and failed. If you can come up with a shorter one-liner, feel free to leave it in the comments. It needs to be general (it can't assume a specific iPhone ID, for example), and needs to assume a very large number of files in the backup directory (such that "grep '#\!AMR' *" would likely fail due to "*" being too long; that happens to be the case for me). Other than that, have fun.
24 Responses to Saving Voicemail on a non-Jailbroken iPhone
Newbie December 6, 2009
I was having the same trouble, except it wasn't for an amr file. But why not use the "file" command instead? It gave something like ($1 is the argument)
pushd "$1″
for i in *mddata; do
if [[ "`file "$i" |grep -i 'data$' |grep -v -i "image" |wc -l`" -gt 0 ]] ; then
echo "$i"
cp $i ../
fi
done
popd
In my case, I was looking for "data" file types, but not jpeg nor png images, which respond to file by "JPEG data image", so that's why I used a grep -v, to get rid of those files. I don't know if it's more efficient, but I wanted to share this one, in case anyone wanted to find other types of files stored on their iPhones. (Sadly, the files I was looking for were in /var/mobile/Media, which isn't backed up
)
Marty January 23, 2010
brilliant! thanks.
Seren May 10, 2010
I had some problems with the script, due to the grep section.
This didn't work:
grep -la "#\!AMR" {} +
This did however:
grep -la '#!AMR' {} \;
The working version is:
pushd ~/Library/Application\ Support/MobileSync/Backup ; for I in `find . -name *.mddata -exec grep -la '#!AMR' {} \;` ; do cp $I $OLDPWD/`basename -s mddata $I`amr ; done ; popd
ericb May 10, 2010
The "+" sign ending for the find command works for me (OS X 10.6), and does something slightly different, but the "\;" ending is probably more compatible with various versions of find, so I've updated the original post with your suggestion. Thanks!
tim June 7, 2010
ok, we need a windows version of this method
Richard Owen June 24, 2011
See my later post:
http://strangelydim.com/2009/11/24/saving-voicemail-on-a-non-jailbroken-iphone/comment-page-1/#comment-255
Justin Smith June 21, 2010
I have been using this little program from Decipher to save my voicemails as mp3s files. I'm on a mac though, so I'm not sure about whether it works for windows or not! ; ) Cheers and hope that might be useful.
http://decipher-media.com/iphone-tools/
ericb June 21, 2010
Looks like this might be a good choice for folks who are a bit gun-shy at the command-line – at 5 bucks, it's a lot more reasonable than The Missing Sync if all you need is voicemail.
Lorna February 21, 2012
at that link I see an application for saving text messages, but, not phone messages…
fred October 3, 2010
with backups made after upgrading to iOS 4, this line needs to be tweaked, as there are no more mddata files.
ericb October 3, 2010
Nuts – I'm still on an original iPhone, so no iOS 4.x for me. I'm still foolishly holding out hope that AT&T won't be the only carrier option in the U.S. come January. A man can dream.
Raj More October 24, 2010
I have Windows 7, iTunes 10.0.1.22 and iPhone 4G with OS 4.1
This script does not work for me. I get an error saying
bash: pushd: /home/Raj.More/Library/Application Support/MobileSync/Backup: No such file or directory
bash: popd: directory stack empty
ericb October 24, 2010
Hi Raj,
The script was just for OS X users, though it sounds like you must have Cygwin installed to be getting as far as getting an error from bash. I don't have a Windows 7 machine to try something similar on, with or without Cygwin… and according to Fred above, there are no more .mddata files with iOS 4.x. Soon as I get an iPhone 4 (hopefully on Verizon), I'll update the script.
Richard Owen June 24, 2011
See my later post for doing this on Windows:
http://strangelydim.com/2009/11/24/saving-voicemail-on-a-non-jailbroken-iphone/comment-page-1/#comment-255
Edward H January 5, 2011
Hello Eric,
I am desperate for your assistance. Somehow AT&T wiped out all of my saved voicemails during an upgrade on my iPhone 4 from the original OS (4.0) to the current OS (4.2.1). The voicemails wiped out were only saved ones (about 20 or so), new, unlistened to messages (2 from October), were retained and accessible. I contacted AT&T and after a couple hours between different departments, i was told my messages are gone!
My hope is that I can retrieve the messages from a backup file. The reason for the dire need of the files is that I have messages from my mother (she unexpectantly passed away in October) to my kids, singing happy birthday and other fond memories.
If you have any suggestions I would be highly appreciative and grateful for your efforts. Thank you!
ericb January 5, 2011
Yikes – I hope you're able to recover the voicemail! I still don't have an iPhone 4, so I still can't help directly, but if you're on a Mac, I'd try Justin Smith's suggestion (above) for Decipher VoiceMail. It supposedly works on later versions of iOS, and is probably more tested than my hack method. I haven't tried it personally, but it's probably worth a shot.
If you're on Windows, you might be stuck with the much more expensive The Missing Sync. In either case, I'd say one of those two is going to be your best bet – hopefully you have a backup that was made recently enough to have the voicemails. I would probably avoid creating any new backups for the time being just in case a newer backup might overwrite an older one.
Darlene Wong January 28, 2011
Thanks for sharing this tip. I am running iOS 4.2.1 on an iPhone 3G. The following modification works for me:
pushd ~/Library/Application\ Support/MobileSync/Backup ; for I in `find . -name "*" -exec grep -la '#\!AMR' {} \;` ; do cp $I $OLDPWD/$I.amr; done ; popd
Andrew B May 10, 2012
Thanks. I needed to look at non-mddata files as well.
Richard Owen June 24, 2011
For Windows:
Get the free 'file' command:
http://gnuwin32.sourceforge.net/packages/file.htm
For Windows XP go to: \Documents and Settings\(username)\Application Data\Apple Computer\MobileSync\Backup\
For Windows Vista and Windows 7 I've heard it is this, but have not confirmed:
\Users\(username)\AppData\Roaming\Apple Computer\MobileSync\Backup\
The voicemails (I did this on XP) are in files with no extension. The file command can figure out which files are audio files and the following command line (you will need to modify it to include it in a batch file) uses the file command to copy off the audio files (they are all voicemails it seems) to .amr files which can be read by QuickTime or maybe the Real Player:
@for %f in (*.) do @(for /F "usebackq tokens=1,2* delims=; " %g in (`file %f`) do @(if %h==Adaptive copy %g %g.amr))
I also learned from this post, so credit due:
http://www.instructables.com/id/How-to-Download-Voicemail-from-an-iPhone/
ericb August 25, 2011
Ack – sorry, Richard – your very helpful comment got lost in the moderation queue until I found it just now. Apologies!
denis2342 March 18, 2012
You can also append -Rp to the cp command to get the date when the voicemail was backupped. sadly appe does not copy to original date of the voicemail while backupping.
Denis
Miss V. June 21, 2012
Hi there! I ran the script in terminal and it directed me to a Library/Application Support/MobileSync/Backup folder where all I have are thousands of text files.
Could you kindly explain how I can get to my amr file? I have a very meaningful voice mail that I can't lose, but I work on a Mac with an unlocked (and not jailbroken) iPhone 4S on the Tmobile network, so I'm all kinds of screwed because most apps are for JB phones, or work only if you have visual voice mail (which if you have Tmobile you don't have).
Your solution is the most elegant and the only one that seems like it will work for me but perhaps I'm not doing it right…
Bill October 13, 2012
The following command should work the same in Windows 7 with just the built-in commands (you don't need to download the 'file' command):
FOR /F "usebackq delims=;" %I IN (`FINDSTR /B /L /M /S "#!AMR" "%USERPROFILE%\AppData\Roaming\Apple Computer\MobileSync\Backup\*"`) DO @COPY %~fI .\%~nI.amr