{"id":2131,"date":"2016-09-15T21:36:31","date_gmt":"2016-09-15T20:36:31","guid":{"rendered":"https:\/\/denbeke.be\/blog\/?p=2131"},"modified":"2017-10-16T08:28:16","modified_gmt":"2017-10-16T07:28:16","slug":"exporting-messages-and-attachments-from-iphone-to-mac","status":"publish","type":"post","link":"https:\/\/denbeke.be\/blog\/mac\/exporting-messages-and-attachments-from-iphone-to-mac\/","title":{"rendered":"Exporting messages and attachments from iPhone to Mac"},"content":{"rendered":"<p>Yesterday I accidentally deleted an important sms conversation from my Mac (for which I didn&#8217;t have a Time Machine backup). I thought it would be fairly easy to copy all my messages from my iPhone to my Mac, but it wasn&#8217;t that easy&#8230;<\/p>\n<p>This guides helps you copy all your messages from iOS to OS X. You could invert the process to copy your messages from OS X to iOS.<\/p>\n<h3 id=\"copying-the-databases\">Copying the databases<\/h3>\n<p>Before continuing, quit Messages app on your Mac.<\/p>\n<p>First you need <code>sms.db<\/code> and <code>Attachments<\/code> folder from the iPhone. You can use a backup extractor tool to restore the file structure.<br \/>\nYou can also manually find the backup folder in <code>~\/Library\/Application Support\/MobileSync\/Backup<\/code>. The files in that backup folder are named with the SHA-1 hash of the original file in the iOS filesystem. The file for <code>sms.db<\/code> is called <code>3d0d7e5fb2ce288813306e4d4636395e047a3d28<\/code>. Just rename it to <code>sms.db<\/code> and you have your SMS database. (I extracted the attachments folder with a third-party app)<\/p>\n<p>Now backup <code>~\/Library\/Messages<\/code> on your Mac and replace all its contents with <code>sms.db<\/code> and <code>Attachments<\/code> from your iPhone. Rename <code>sms.db<\/code> to <code>chat.db<\/code>.<\/p>\n<p>Remove the <code>~\/Library\/Containers\/com.apple.iChat<\/code> folder.<\/p>\n<h3 id=\"fixing-attachments\">Fixing attachments<\/h3>\n<p>On iOS, the messages are stored in <code>~\/Library\/SMS\/<\/code> directory. This is not the case on OS X, where they are stored in <code>~\/Library\/Message\/<\/code>. This results in your attachments not showing op in Messages on Mac. In order to solve this, we need to execute a Sqlite query to rename <em>SMS<\/em> to <em>Messages<\/em> for each attachment:<\/p>\n<pre><code>UPDATE attachment\r\nSET \r\n  filename = replace(filename, '\/Library\/SMS\/Attachments\/', '\/Library\/Messages\/Attachments\/')\r\nWHERE\r\n  filename LIKE '%\/Library\/SMS\/Attachments\/%';<\/code><\/pre>\n<p>I used <a href=\"http:\/\/sqlitebrowser.org\" target=\"_blank\" rel=\"noopener\">DB Browser for SQLite<\/a> to browse and edit the SQL database. You can execute the above SQL query by going to the <em>Execute SQL<\/em> tab.<\/p>\n<h3 id=\"fixing-version\">Fixing version<\/h3>\n<p>It is also possible that you need to update the Sqlite version number. Otherwise Messages.app will mark the database file as incompatible. Again, we do this by executing a query:<\/p>\n<pre><code>UPDATE _SqliteDatabaseProperties\r\nSET\r\n    value = '9007'\r\nWHERE key = '_ClientVersion';<\/code><\/pre>\n<p><em>I got the <code>9007<\/code> value from the <code>chat.db<\/code> database.<\/em><\/p>\n<h3 id=\"restart\">Restart<\/h3>\n<p>Once all of this is done, restart your Mac and verify that your messages have arrived in Messages app.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Yesterday I accidentally deleted an important sms conversation from my Mac (for which I didn&#8217;t have a Time Machine backup). I thought it would be fairly easy to copy all my messages from my iPhone to my Mac, but it wasn&#8217;t that easy&#8230; This guides helps you copy all your messages from iOS to OS [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[114,161],"tags":[129,126,149,224],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v15.6.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Exporting messages and attachments from iPhone to Mac &ndash; DenBeke<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/denbeke.be\/blog\/mac\/exporting-messages-and-attachments-from-iphone-to-mac\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Exporting messages and attachments from iPhone to Mac &ndash; DenBeke\" \/>\n<meta property=\"og:description\" content=\"Yesterday I accidentally deleted an important sms conversation from my Mac (for which I didn&#8217;t have a Time Machine backup). I thought it would be fairly easy to copy all my messages from my iPhone to my Mac, but it wasn&#8217;t that easy&#8230; This guides helps you copy all your messages from iOS to OS [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/denbeke.be\/blog\/mac\/exporting-messages-and-attachments-from-iphone-to-mac\/\" \/>\n<meta property=\"og:site_name\" content=\"DenBeke\" \/>\n<meta property=\"article:published_time\" content=\"2016-09-15T20:36:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-10-16T07:28:16+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary\" \/>\n<meta name=\"twitter:creator\" content=\"@MthsBk\" \/>\n<meta name=\"twitter:site\" content=\"@MthsBk\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data1\" content=\"2 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/denbeke.be\/blog\/#website\",\"url\":\"https:\/\/denbeke.be\/blog\/\",\"name\":\"DenBeke\",\"description\":\"Mathias Beke\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/denbeke.be\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/denbeke.be\/blog\/mac\/exporting-messages-and-attachments-from-iphone-to-mac\/#webpage\",\"url\":\"https:\/\/denbeke.be\/blog\/mac\/exporting-messages-and-attachments-from-iphone-to-mac\/\",\"name\":\"Exporting messages and attachments from iPhone to Mac &ndash; DenBeke\",\"isPartOf\":{\"@id\":\"https:\/\/denbeke.be\/blog\/#website\"},\"datePublished\":\"2016-09-15T20:36:31+00:00\",\"dateModified\":\"2017-10-16T07:28:16+00:00\",\"author\":{\"@id\":\"https:\/\/denbeke.be\/blog\/#\/schema\/person\/386878f712fe3fe22227216f087772dc\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/denbeke.be\/blog\/mac\/exporting-messages-and-attachments-from-iphone-to-mac\/\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/denbeke.be\/blog\/#\/schema\/person\/386878f712fe3fe22227216f087772dc\",\"name\":\"Mathias Beke\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/denbeke.be\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/015ba35e6ce4f5859e3888ca99807575?s=96&d=mm&r=g\",\"caption\":\"Mathias Beke\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/posts\/2131"}],"collection":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/comments?post=2131"}],"version-history":[{"count":2,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/posts\/2131\/revisions"}],"predecessor-version":[{"id":2260,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/posts\/2131\/revisions\/2260"}],"wp:attachment":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/media?parent=2131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/categories?post=2131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/tags?post=2131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}