{"id":3085,"date":"2014-06-23T08:19:56","date_gmt":"2014-06-23T07:19:56","guid":{"rendered":"http:\/\/www.colinmcnulty.com\/blog\/?p=3085"},"modified":"2014-06-23T08:20:45","modified_gmt":"2014-06-23T07:20:45","slug":"hey-where-did-my-comment-go","status":"publish","type":"post","link":"https:\/\/www.colinmcnulty.com\/blog\/2014\/06\/23\/hey-where-did-my-comment-go\/","title":{"rendered":"Hey, where did my comment go?"},"content":{"rendered":"<p>There&#8217;s a saying in the IT world: &#8220;If it ain&#8217;t broke, don&#8217;t fix it!&#8221; or perhaps that&#8217;s just the advice my Dad gave me.<\/p>\n<p>Either way, I failed to follow that advice and things have gone wrong.  An innocuous little tweak has ended up with over half of the posts on this site disappearing.<\/p>\n<p>Oddly (or typically if you work in IT) reversing the very small change I made does not seem to solve the problem, which is a major pain.<\/p>\n<p>Not to worry, I do at least take regular backups of this site, so it should just be a matter of restoring from the backup immediately prior to the change I&#8217;d made.  Unfortunately, nothing in IT is ever that simple.  I kept getting WordPress backup import restore errors like this:<\/p>\n<p><strong>> Duplicate entry &#8216;15878&#8217; for key &#8216;PRIMARY&#8217;<\/strong><\/p>\n<p>For some reason the backups I took duplicated many of the comment records, actually in the .sql.gz backup file.  I have no idea why this happened, but I had to manually remove the duplicates by deleting one of the offending duplicate INSERT sql statements.  Here&#8217;s an example of an offending line (email address changed):<\/p>\n<p>\tINSERT INTO `wp_comments` VALUES (15878, 192, &#8216;Eric&#8217;, &#8216;eric@eric.com&#8217;, &#8216;Eric&#8217;s comment was here&#8217;, 0, &#8216;1&#8217;, &#8216;Mozilla\/5.0 (Windows NT 6.1; rv:10.0.2) Gecko\/20100101 Firefox\/10.0.2&#8217;, &#8221;, 0, 0, &#8216;N&#8217;, &#8216;0&#8217;); <\/p>\n<p>The really annoying thing was that there&#8217;s no way to tell which comments were duplicated without just trying to do the import.  This was the process I had to follow, on the database&#8217;s Import tab in phpMyAdmin from the cPanel:<\/p>\n<p>&#8211; Select the .sql.gz backup file for import<br \/>\n&#8211; Click GO<br \/>\n&#8211; Wait for it to upload and start the import<br \/>\n&#8211; Check the error for the primary key number it was moaning about.<br \/>\n&#8211; Unzip the .gz file to get the .sql<br \/>\n&#8211; Edit the .sql file and search for the offending primary key number<br \/>\n&#8211; Delete one of the duplicates<br \/>\n&#8211; Save the .sql file<br \/>\n&#8211; Find the .sql file in Windows Explorer and zip it up, ensuring it&#8217;s .gzip format<br \/>\n&#8211; Repeat the import process <\/p>\n<p>That&#8217;s it, for each duplicate, of which there were over 10!<\/p>\n<p>Anyway, the long point of this post is that if you posted a comment on this bloc between 22nd May and 23rd June, it&#8217;s probably gone.  <strong>I&#8217;m very sorry about that<\/strong>, as I do appreciate and read every comment that&#8217;s posted.  Please re-post it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There&#8217;s a saying in the IT world: &#8220;If it ain&#8217;t broke, don&#8217;t fix it!&#8221; or perhaps that&#8217;s just the advice my Dad gave me. Either way, I failed to follow that advice and things have gone wrong. An innocuous little tweak has ended up with over half of the posts on this site disappearing. Oddly [&hellip;]<\/p>\n","protected":false},"author":161,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[342,344,343,10],"class_list":{"0":"post-3085","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-uncategorized","7":"tag-backup","8":"tag-error","9":"tag-restore","10":"tag-wordpress"},"_links":{"self":[{"href":"https:\/\/www.colinmcnulty.com\/blog\/wp-json\/wp\/v2\/posts\/3085","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.colinmcnulty.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.colinmcnulty.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.colinmcnulty.com\/blog\/wp-json\/wp\/v2\/users\/161"}],"replies":[{"embeddable":true,"href":"https:\/\/www.colinmcnulty.com\/blog\/wp-json\/wp\/v2\/comments?post=3085"}],"version-history":[{"count":2,"href":"https:\/\/www.colinmcnulty.com\/blog\/wp-json\/wp\/v2\/posts\/3085\/revisions"}],"predecessor-version":[{"id":3088,"href":"https:\/\/www.colinmcnulty.com\/blog\/wp-json\/wp\/v2\/posts\/3085\/revisions\/3088"}],"wp:attachment":[{"href":"https:\/\/www.colinmcnulty.com\/blog\/wp-json\/wp\/v2\/media?parent=3085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.colinmcnulty.com\/blog\/wp-json\/wp\/v2\/categories?post=3085"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.colinmcnulty.com\/blog\/wp-json\/wp\/v2\/tags?post=3085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}