{"id":367,"date":"2012-02-17T00:48:06","date_gmt":"2012-02-17T05:48:06","guid":{"rendered":"http:\/\/littlesvr.ca\/grumble\/?p=367"},"modified":"2012-12-05T00:47:10","modified_gmt":"2012-12-05T05:47:10","slug":"homebrewed-live-server-migration","status":"publish","type":"post","link":"http:\/\/littlesvr.ca\/grumble\/2012\/02\/17\/homebrewed-live-server-migration\/","title":{"rendered":"Homebrewed live server migration"},"content":{"rendered":"<p><a href=\"http:\/\/littlesvr.ca\/grumble\/2012\/02\/10\/new-littlesvr-ca\/\">I mentioned<\/a> that I&#8217;ll talk about the software migration from the old littlesvr.ca hardware to the new machine. The neat thing is &#8211; I accomplished it in less than a minute of downtime while preserving all my data\/metadata.<\/p>\n<p>Here&#8217;s the <strong>long story<\/strong> (shorter version at the bottom):<\/p>\n<ol>\n<li>First step was to install the OS on the new hardware. This was a full install (just like the old one) of the newest available Slackware version.<\/li>\n<li>At this point I had two servers running, on different internal IPs, both claiming to be littlesvr.ca but only one (the old one) beeing accessible from the internet.<\/li>\n<li>Then I had to remember\/relearn how to use rsync (-avx).<\/li>\n<li>My first sync was from the entire root of the old server into a directory on the home partition on the new one. I&#8217;ve used this tree to set up the services the way I wanted them. Most services I reconfigured manually rather than using the old config files &#8211; partly because I was expecting the newer versions to have different options (which was sort of true with Apache) and partly because I wanted to make sure I&#8217;ve done it right the first time (mostly I have).<\/li>\n<li>Don&#8217;t underestimate the step above, that was a lot of work. Things I have completely forgotten about such as my aliases.db file and the stunnel config had to be accounted for.<\/li>\n<li>Originally I was going to keep all the keys from the old server, but instead I&#8217;ve decided to consolidate the keys and now I have one set for most of the services I use. Yeah, yeah, whatever.<\/li>\n<li>I also needed to migrate my MySQL databases (of which I have a few). It turned out that just copying \/var\/lib\/mysql isn&#8217;t enough, so I had to make an SQL dump of the old database and restore it on the new server. That approach had these problems:\n<ul>\n<li>The old database wasn&#8217;t as secure as I liked, it still had the test db in it, and though I&#8217;m sure I went through the users thoroughly, I wasn&#8217;t sure enough.<\/li>\n<li>The dump included the &#8220;mysql&#8221; database, which had some tables that changed slightly in the newer version. So mysql refused to work properly.<\/li>\n<\/ul>\n<\/li>\n<li>So even after doing a dump, and transferring the dump over to the new server, and importing it, I still needed to run a couple of commands to secure the databases and make MySQL happy.<\/li>\n<li>The second rsync was more complex. Here I had to sync my home directories (lots of static\/dynamic data), the SQL, and \/var\/spool\/mail.<\/li>\n<li>And now the magic:<\/li>\n<\/ol>\n<p>This is the short version, and <strong>the interesting part<\/strong>, here&#8217;s what I did:<\/p>\n<ol>\n<li>Opened up my router web configuration page in the browser, navigated to the port forwarding page, and changed all the IPs for forwarded services from the old server&#8217;s LAN address to the new one&#8217;s. But didn&#8217;t save the changes yet.<\/li>\n<li>Stopped all the relevant services on the new server (simple script).<\/li>\n<li>Ran the second rsync again, this completed much quicker than the first time because most of the data was unchanged.<\/li>\n<li>Restarted all the relevant services.<\/li>\n<li>Pressed save on my router config.<\/li>\n<\/ol>\n<p>The trick worked so well I amazed myself :) I happend to be tailing my apache logs on both the old and new server while doing the final steps of the migration, and the second I saved my new port forwarding settings I saw the logs stop on the old server and start on the new one. It was an awesome feeling.<\/p>\n<p>I&#8217;m sure I must have said in the past that rsync is a pain in the ass. I don&#8217;t necessarily take it back &#8211; but I will say I appreciated having such a powerful tool that day.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I mentioned that I&#8217;ll talk about the software migration from the old littlesvr.ca hardware to the new machine. The neat thing is &#8211; I accomplished it in less than a minute of downtime while preserving all my data\/metadata. Here&#8217;s the long story (shorter version at the bottom): First step was to install the OS on &hellip; <\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4],"tags":[],"class_list":{"0":"entry","1":"post","2":"publish","3":"author-andrew","4":"post-367","6":"format-standard","7":"category-opensource","8":"category-safeforseneca"},"_links":{"self":[{"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/posts\/367","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/comments?post=367"}],"version-history":[{"count":2,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/posts\/367\/revisions"}],"predecessor-version":[{"id":569,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/posts\/367\/revisions\/569"}],"wp:attachment":[{"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/media?parent=367"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/categories?post=367"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/tags?post=367"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}