{"id":185,"date":"2018-09-03T19:40:29","date_gmt":"2018-09-03T19:40:29","guid":{"rendered":"http:\/\/www.beer.org\/blog\/?p=185"},"modified":"2018-09-03T19:40:29","modified_gmt":"2018-09-03T19:40:29","slug":"recover-your-zoneminder-data-after-inadvertent-loss-of-ib_logfile01","status":"publish","type":"post","link":"https:\/\/www.beer.org\/blog\/index.php\/2018\/09\/03\/recover-your-zoneminder-data-after-inadvertent-loss-of-ib_logfile01\/","title":{"rendered":"Recover your zoneminder data after inadvertent loss of ib_logfile[01]"},"content":{"rendered":"<p>In the unlikely event that you&#8217;ve lost your Mysql ib_logfile[01] files, you will google and try to figure out whether you can get the data back.\u00a0 All the googling will tell you that all of your data is in those log files but that&#8217;s not true as of any recent version of mysql.\u00a0 I was looking around in \/var\/lib\/mysql\/zm\/ and noticed the .ibd files were sizable which suggested the data was actually in there instead.\u00a0 After some googling, I found you can import data back into a freshly created Zoneminder DB.<\/p>\n<p>I decided to uninstall\/reinstall zoneminder\u00a0 from scratch and then recreate the DB:<\/p>\n<p>https:\/\/stackoverflow.com\/questions\/18761594\/how-do-i-do-a-clean-re-install-of-zoneminder<\/p>\n<p>After doing that, I did the following:<\/p>\n<p>(there are shell commands interspersed with the mysql commands so you can see the order of operations):<\/p>\n<p>&nbsp;<\/p>\n<blockquote>\n<p style=\"padding-left: 30px;\">lock tables Devices write;<br \/>\nalter table Devices discard tablespace;<br \/>\n# cp -p saved\/Devices.idb \/var\/lib\/mysql\/zm\/<br \/>\nalter table Devices import tablespace;<\/p>\n<p style=\"padding-left: 30px;\">lock tables Events write;<br \/>\nalter table Events discard tablespace;<br \/>\n# cp -p saved\/Events.idb \/var\/lib\/mysql\/zm\/<br \/>\nalter table Events import tablespace;<\/p>\n<p style=\"padding-left: 30px;\">lock tables Filters write;<br \/>\nalter table Filters discard tablespace;<br \/>\n# cp -p saved\/Filters.idb \/var\/lib\/mysql\/zm\/<br \/>\nalter table Filters import tablespace;<\/p>\n<p style=\"padding-left: 30px;\">lock tables Frames write;<br \/>\nalter table Frames discard tablespace;<br \/>\n# cp -p saved\/Frames.idb \/var\/lib\/mysql\/zm\/<br \/>\nalter table Frames import tablespace;<\/p>\n<p style=\"padding-left: 30px;\">lock tables Groups write;<br \/>\nalter table Groups discard tablespace;<br \/>\n# cp -p saved\/Groups.idb \/var\/lib\/mysql\/zm\/<br \/>\nalter table Groups import tablespace;<\/p>\n<p style=\"padding-left: 30px;\">lock tables Logs write;<br \/>\nalter table Logs discard tablespace;<br \/>\n# cp -p saved\/Logs.idb \/var\/lib\/mysql\/zm\/<br \/>\nalter table Logs import tablespace;<\/p>\n<p style=\"padding-left: 30px;\">lock tables MonitorPresets write;<br \/>\nalter table MonitorPresets discard tablespace;<br \/>\n# cp -p saved\/MonitorPresets.idb \/var\/lib\/mysql\/zm\/<br \/>\nalter table MonitorPresets import tablespace;<\/p>\n<p style=\"padding-left: 30px;\">lock tables Monitors write;<br \/>\nalter table Monitors discard tablespace;<br \/>\n# cp -p saved\/Monitors.idb \/var\/lib\/mysql\/zm\/<br \/>\nalter table Monitors import tablespace;<\/p>\n<p style=\"padding-left: 30px;\">lock tables Servers write;<br \/>\nalter table Servers discard tablespace;<br \/>\n# cp -p saved\/Servers.idb \/var\/lib\/mysql\/zm\/<br \/>\nalter table Servers import tablespace;<\/p>\n<p style=\"padding-left: 30px;\">lock tables States write;<br \/>\nalter table States discard tablespace;<br \/>\n# cp -p saved\/States.idb \/var\/lib\/mysql\/zm\/<br \/>\nalter table States import tablespace;<\/p>\n<p style=\"padding-left: 30px;\">lock tables TriggersX10 write;<br \/>\nalter table TriggersX10 discard tablespace;<br \/>\n# cp -p saved\/TriggersX10.idb \/var\/lib\/mysql\/zm\/<br \/>\nalter table TriggersX10 import tablespace;<\/p>\n<p style=\"padding-left: 30px;\">lock tables Users write;<br \/>\nalter table Users discard tablespace;<br \/>\n# cp -p saved\/Users.idb \/var\/lib\/mysql\/zm\/<br \/>\nalter table Users import tablespace;<\/p>\n<p style=\"padding-left: 30px;\">lock tables ZonePresets write;<br \/>\nalter table ZonePresets discard tablespace;<br \/>\n# cp -p saved\/ZonePresets.idb \/var\/lib\/mysql\/zm\/<br \/>\nalter table ZonePresets import tablespace;<\/p>\n<p style=\"padding-left: 30px;\">lock tables Zones write;<br \/>\nalter table Zones discard tablespace;<br \/>\n# cp -p saved\/Zones.idb \/var\/lib\/mysql\/zm\/<br \/>\nalter table Zones import tablespace;<\/p>\n<\/blockquote>\n<p>After that, &#8216;systemctl restart zoneminder&#8217; and hope for the best.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the unlikely event that you&#8217;ve lost your Mysql ib_logfile[01] files, you will google and try to figure out whether you can get the data back.\u00a0 All the googling will tell you that all of your data is in those log files but that&#8217;s not true as of any recent version of mysql.\u00a0 I was&#8230; <a class=\"moretag\" href=\"https:\/\/www.beer.org\/blog\/index.php\/2018\/09\/03\/recover-your-zoneminder-data-after-inadvertent-loss-of-ib_logfile01\/\">Continue reading &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-185","post","type-post","status-publish","format-standard","hentry","category-tech-stuff"],"_links":{"self":[{"href":"https:\/\/www.beer.org\/blog\/index.php\/wp-json\/wp\/v2\/posts\/185","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.beer.org\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.beer.org\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.beer.org\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.beer.org\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=185"}],"version-history":[{"count":1,"href":"https:\/\/www.beer.org\/blog\/index.php\/wp-json\/wp\/v2\/posts\/185\/revisions"}],"predecessor-version":[{"id":186,"href":"https:\/\/www.beer.org\/blog\/index.php\/wp-json\/wp\/v2\/posts\/185\/revisions\/186"}],"wp:attachment":[{"href":"https:\/\/www.beer.org\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=185"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.beer.org\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=185"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.beer.org\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=185"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}