Sunday, April 10, 2011

Fresh Start

So, it looks like I'm starting over with the Blog thing. I had one hosted with a previous employer then moved to a new job (moving my website to them) and when I left that job, they promptly deleted my site after assuring me it was fine to leave it there. Looks like there is no such thing as honor anymore; you can say one thing and then do another and it's okay. Oh well. I can just add that to the list of things they screwed me over with.

Fortunately, I was able to figure out how to restore all of my posts (and the comments) so it looks like I don't really have to start over. Good thing I am such a nerd. Read on if you wish to discover the depths of my nerdosity.


The Back Story: I worked for an ISP where I had setup my own personal Domain, Email services, and website with a WordPress Blog. When my employment ended and I moved to another firm, I migrated my Website (and the Blog) to their Web Servers. That process was easy: Log into the WordPress Admin Interface on the old server, export the posts/comments to a file, import that file to the new server, and then just tweak a few things that might have cropped up due to different web servers (or just different versions of the same Web Server application), Database Servers, Web Extensions (Java/PHP/CGI/etc), etc. Then, I was unexpectedly let go from that employer and assured that I could leave my Website/Blog there as it wasn't revenue generating and had very little traffic and that these people weren't jerks who would just arbitrarily delete my stuff out of spite. A few weeks afterwards, I logged into my Blog to update some things and I just happened to do a backup of the database to my local computer as part of that update process. Fours days later, I went to log in again and behold; it no longer exists. I can't find it anywhere; no website, no FTP access, no nothing. It is GONE. I emailed my former employers to inquire about this and the reply was basically "Yeah. We rebuilt that server after backing up the "important" sites but we didn't bother with yours because, well, we really couldn't give a shit about your stuff. We can put your site back but don't expect us to bother restoring the blog or anything else". Well, that's peachy. The Blog was the only thing I really even used; if only occasionally.  I could've done it easily myself for them but due to legal reasons, I really didn't think it was appropriate for me to access the server so I just accepted the fact that this place screwed me over on yet another front (the whole list of things they have done is a subject of it's own blog posting. I'll get around to that later).

The Problem: Restore a WordPress Blog to a new host/provider (and possibly a different platform like Blogger, Tumblr, Posterous, etc) when you no longer have access to the web server itself or the web application. All you have is a relatively current copy of the MySQL database but no existing Web Server or Database server. I decided on Blogger and even though I found an online converter, I can't just upload my database; I need to have WordPress up so I can export everything to an XML file and upload that.

The Solution (The Easy One): Just say the hell with it and accept the fact that if you want a Blog, you need to start from scratch or try to recreate each entry manually on your new provider. Otherwise, you are just S.O.L.

The Solution (The Not-Easy One): I'm not one to give up when presented with a problem or task. I will find a way to make it happen or I will find the person/people who can. So, given that and what I had to work with, I decided to tackle this particular issue; there's nothing I can't do if I put my mind to it. Besides, "can't" never really could do much of anything, and I do not believe in "can't". Well, here we go...

Firstly, if I had a database but no database server and I had a web-based application but no web server, I need to rectify these two items first. Web server could be Apache or Microsoft Internet Information Services (IIS); I am much more familiar with IIS and considering that was what the blog ran on before, that seemed like the obvious choice. Secondly, WordPress uses MySQL only so, like it or not, that was the database server I needed to get set up.

Initial requirements now determined (MySQL and IIS), it was time to do it. IIS was pretty easy; I'm running Windows 7 on my laptop so it was just a matter of adding that Feature in Programs and Features. Next I needed to install MySQL. Again, pretty straightforward. I'm not too well versed on using MySQL from the command line so I opted to also set up phpMyAdmin so I could have a GUI but for that I would need to enable FastCGI and PHP extensions in IIS 7. Are we having fun yet? I sure was.

So, I get IIS, MySQL, phpMyAdmin, and FastCGI/PHP all set up. Now I figured I should go ahead and import the MySQL database. I create a new database in phpMyAdmin and import the backup and sure enough, I can see all of my Blog entires and comments. So far, so good.

Here's where I ran into potholes. I found an application called the Microsoft Web Platform Installer. This application apparently allows you to quickly and easily install various applications on IIS and easily set them up (along with any dependencies). AWESOME! I get it installed and have it install WordPress. I tell the installer to point to the database I had imported, entered the DB username/password and a few other things. Then the installer takes off and does it's thing. It downloads and installs WordPress but then I noticed it was also installing MySQL again. What? It's already installed and I told it to use an existing database. Turns out, this application didn't recognize that I had the latest version of MySQL and installed an older version and created a new database. Not really a big problem as this is all just temporary so I can get the my Blog posts.

The primary issue is that I need to use phpMyAdmin to access the database and the installer didn't say anything about what URL the new instance was running on, what port it's using, or what the login information is. Pfft. I uninstall WordPress, the new (old version) of MySQL and just download WordPress and do it's "Famous 5 Minute Install". I edited config file as instructed, pointing it at the database I'd imported earlier and get a "WordPress is already installed. Please login to continue" message. I assume it sees that there are certain things in the database that tells the installer everything is already set up. So, I try to log in; none of the usernames and passwords I have ever used for my blog are working. Grrrr.

Time to back up a bit. I'll create a new, empty database, point WP at it, and then import from the old database to the new one. I get all of this done, run the installer, and login into WordPress. Now that I know it's running and everything looks great, I import the old database and then try to log back into WordPress. I get the same username/password error. Crap. I delete the database I'd just created, create a new one, run the setup program again, and try to import again, only this time, I only import the tables containing the posts and the comments. Now everything is there. So, it looks like I'm good to go on the final step of exporting the XML file and converting it so I can upload it to Blogger.

In WordPress, I export everything and then try to run it through the converter and it kicks back a JavaScript error. Shit. I sure hope I don't end up having to just recreate every post manually. That was kind of the reason for all of this. It'd suck to have spent a few hours doing this only to find that I was going to have to do it the hard way after all.

Back in WP, I only export the Comments and run that through the converter. It works like a champ! I try the posts and get the same error, only this time there's a bit more information; a javascript error and a line number in the XML file where it starts. I open the XML file and behold! I see the problem. On my original Blog, I had inserted some JavaScript for Google Analytics so I could track page views, demographics, etc. Apparently, the converter didn't like that code (which is odd because Blogger is a Google service...). Well, that means I do have to do some manual stuff; I go through all of the posts (45+ posts) and delete the JavaScript and export everything again. This time, it works great. SUWEET!

I log into Blogger and import the file I got from the converter and BAM!!! It's all there and except for a few odd characters and some formatting, it looks great.

So, mission accomplished. In and of itself, the process wasn't too difficult; I just hit a few snags and learned some things in the process. It just reinforces my belief that there is nothing you can't do and no such thing as a big problem; just a series of small obstacles. If someone else benefits from my experience, that's even better.

I think it's time for a beer. :-)

No comments:

Post a Comment