{"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":{"footnotes":""},"categories":[114,161],"tags":[129,126,149,224],"class_list":["post-2131","post","type-post","status-publish","format-standard","hentry","category-mac","category-software","tag-ios","tag-iphone","tag-os-x","tag-sql","entry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Exporting messages and attachments from iPhone to Mac &#8211; 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 &#8211; 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=\"author\" content=\"Mathias Beke\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@MthsBk\" \/>\n<meta name=\"twitter:site\" content=\"@MthsBk\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mathias Beke\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/mac\\\/exporting-messages-and-attachments-from-iphone-to-mac\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/mac\\\/exporting-messages-and-attachments-from-iphone-to-mac\\\/\"},\"author\":{\"name\":\"Mathias Beke\",\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/#\\\/schema\\\/person\\\/386878f712fe3fe22227216f087772dc\"},\"headline\":\"Exporting messages and attachments from iPhone to Mac\",\"datePublished\":\"2016-09-15T20:36:31+00:00\",\"dateModified\":\"2017-10-16T07:28:16+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/mac\\\/exporting-messages-and-attachments-from-iphone-to-mac\\\/\"},\"wordCount\":326,\"commentCount\":28,\"keywords\":[\"ios\",\"iphone\",\"os x\",\"sql\"],\"articleSection\":[\"Mac\",\"Software\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/denbeke.be\\\/blog\\\/mac\\\/exporting-messages-and-attachments-from-iphone-to-mac\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/mac\\\/exporting-messages-and-attachments-from-iphone-to-mac\\\/\",\"url\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/mac\\\/exporting-messages-and-attachments-from-iphone-to-mac\\\/\",\"name\":\"Exporting messages and attachments from iPhone to Mac &#8211; 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\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/mac\\\/exporting-messages-and-attachments-from-iphone-to-mac\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/denbeke.be\\\/blog\\\/mac\\\/exporting-messages-and-attachments-from-iphone-to-mac\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/mac\\\/exporting-messages-and-attachments-from-iphone-to-mac\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Exporting messages and attachments from iPhone to Mac\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/\",\"name\":\"DenBeke\",\"description\":\"Mathias Beke\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/#\\\/schema\\\/person\\\/386878f712fe3fe22227216f087772dc\",\"name\":\"Mathias Beke\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8889cf00cef9570a8f82e7510ed97205ccb7a1a0d2c7e0968a07e1885386f198?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8889cf00cef9570a8f82e7510ed97205ccb7a1a0d2c7e0968a07e1885386f198?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8889cf00cef9570a8f82e7510ed97205ccb7a1a0d2c7e0968a07e1885386f198?s=96&d=mm&r=g\",\"caption\":\"Mathias Beke\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Exporting messages and attachments from iPhone to Mac &#8211; DenBeke","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/denbeke.be\/blog\/mac\/exporting-messages-and-attachments-from-iphone-to-mac\/","og_locale":"en_US","og_type":"article","og_title":"Exporting messages and attachments from iPhone to Mac &#8211; DenBeke","og_description":"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;]","og_url":"https:\/\/denbeke.be\/blog\/mac\/exporting-messages-and-attachments-from-iphone-to-mac\/","og_site_name":"DenBeke","article_published_time":"2016-09-15T20:36:31+00:00","article_modified_time":"2017-10-16T07:28:16+00:00","author":"Mathias Beke","twitter_card":"summary_large_image","twitter_creator":"@MthsBk","twitter_site":"@MthsBk","twitter_misc":{"Written by":"Mathias Beke","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/denbeke.be\/blog\/mac\/exporting-messages-and-attachments-from-iphone-to-mac\/#article","isPartOf":{"@id":"https:\/\/denbeke.be\/blog\/mac\/exporting-messages-and-attachments-from-iphone-to-mac\/"},"author":{"name":"Mathias Beke","@id":"https:\/\/denbeke.be\/blog\/#\/schema\/person\/386878f712fe3fe22227216f087772dc"},"headline":"Exporting messages and attachments from iPhone to Mac","datePublished":"2016-09-15T20:36:31+00:00","dateModified":"2017-10-16T07:28:16+00:00","mainEntityOfPage":{"@id":"https:\/\/denbeke.be\/blog\/mac\/exporting-messages-and-attachments-from-iphone-to-mac\/"},"wordCount":326,"commentCount":28,"keywords":["ios","iphone","os x","sql"],"articleSection":["Mac","Software"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/denbeke.be\/blog\/mac\/exporting-messages-and-attachments-from-iphone-to-mac\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/denbeke.be\/blog\/mac\/exporting-messages-and-attachments-from-iphone-to-mac\/","url":"https:\/\/denbeke.be\/blog\/mac\/exporting-messages-and-attachments-from-iphone-to-mac\/","name":"Exporting messages and attachments from iPhone to Mac &#8211; 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"},"breadcrumb":{"@id":"https:\/\/denbeke.be\/blog\/mac\/exporting-messages-and-attachments-from-iphone-to-mac\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/denbeke.be\/blog\/mac\/exporting-messages-and-attachments-from-iphone-to-mac\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/denbeke.be\/blog\/mac\/exporting-messages-and-attachments-from-iphone-to-mac\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/denbeke.be\/blog\/"},{"@type":"ListItem","position":2,"name":"Exporting messages and attachments from iPhone to Mac"}]},{"@type":"WebSite","@id":"https:\/\/denbeke.be\/blog\/#website","url":"https:\/\/denbeke.be\/blog\/","name":"DenBeke","description":"Mathias Beke","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/denbeke.be\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/denbeke.be\/blog\/#\/schema\/person\/386878f712fe3fe22227216f087772dc","name":"Mathias Beke","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/8889cf00cef9570a8f82e7510ed97205ccb7a1a0d2c7e0968a07e1885386f198?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/8889cf00cef9570a8f82e7510ed97205ccb7a1a0d2c7e0968a07e1885386f198?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8889cf00cef9570a8f82e7510ed97205ccb7a1a0d2c7e0968a07e1885386f198?s=96&d=mm&r=g","caption":"Mathias Beke"}}]}},"_links":{"self":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/posts\/2131","targetHints":{"allow":["GET"]}}],"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}]}}