Skip to content

Figuring Out Drupal Date Posts with Wolfram Alpha + Retrieving an Old Drupal MySQL database

September 28, 2011
by

Go to Wolfram Alpha: http://www.wolframalpha.com

The formula is simple:

“what date is 12.00am January 1st 1970 + 1201470000 seconds?” (minus the quotes)

The 1201470000 is the drupal timestamp in seconds, dated from 12.00am Jan 1st 1970

The reason I am posting this is as follows:

I had kept a blog using Drupal during 2004-7. I hadn’t really troubled myself about how I might possibly migrate from Drupal 4.n to another CMS later, though I kept upgrading Drupal and Mysql, PHP etc. till Drupal 5.n, when I migrated to WordPress – years later (in 2010) after a hiatus of several years. I had given up blogging using Drupal since about v.6.n. as it was overkill for what I was doing and WordPress seemed very attractive and simple (and lots of useful-for-me plug-ins, regularly updated)

The motivation has been to consolidate several different (historical) blogs kept on different servers using different CMSs into one contiguous blog. To bring it all together.

So, anyway, one day 3 or 4 years ago (I forget when), I decided I didn’t need my old Drupal site anymore – I had a mysql dump of the database as a tar.gz file – no problems!

A disaster – what the hell are you meant to do with this?

After years of doing nothing with it and all the category/xml referencing types have changed?

I tried importing it into Drupal 6.n running locally under MAMP (Mac OSX), but the result was a mad woman’s breakfast – that I simply had no idea what to do with.

So, now, about 6 years later, I am running a wordpress blog using MAMP – how to get that old stuff into the new system?

Well, after a bit of faffing around, I figured out that via the MAMP PHPMyAdmin interface that I could simply create a new database (figure it out yourself – I’m just providing hints here for the geeky few who might run across this problem) and import the old nodes.txt file from Drupal 5.n. There are a million other files  – but this one contains my text and links to my old photos/video etc (they may be contained as BLOBS (Binary Large Objects) in your backup cache file (I gave that a miss, after editing php.ini (via Smultron) for MAMP to upload over 32MB data to 264MB – a number big enough to import the largest mysql dump file – but there is no point for me to figure out what to do with it.))

It’s easy to look at these files using TextEdit or some other text editor.

Anyway, if you do any of this, naturally you should quit MAMP and restart the MAMP server to check any changes have effected.

After that, I exported my nodes.txt file as a nodes.xml file and opened it in Safari. (It reports it’s missing the XML references, but that’s of no import)

I suspect I could’ve just used the nodes.txt file anyway, but haven’t bothered to check.

This gave me access to the ‘plain’ text of my old posts (in a nice clear coloured indented format amidst a bunch of lots of other old Drupal XML formatted entries – see below) that I could cutnpaste into my WordPress install in MAMP, running in a Safari window.

Plus, I could calculate the date of the post using the above approach via Wolfram Alpha.

The bit that remains is that, obviously, the hyperlinks to old videos and photos are broken and I don’t have them at all as they are probably BLOBS within the old mysql dump file somewhere.

But I don’t care: I have the original text sources now (all the stuff I wrote at the time) and, given that I don’t have 5 million posts (only at least two dozen), I can recreate those images and video files at higher resolution from my video and photo databases (e.g. iPhoto and video sources shot on DSLRs) – which will make the whole thing look a lot better than it used to.

You see, I was emailing these things from Antarctica over a satellite connection, so they had to be severely downsampled.

So that was my solution to a classic data retrieval problem for a CMS ignoramus. It was a bit onerous, but I am now a lot more careful about how I lock in my content to database systems that use specific file structures that I don’t know how to properly interrogate. And I’m not about to undertake a computer science course to figure out how, either.

I am sure there are programmer-types who might laugh at this approach who could use complicated terminal unixy/sql approaches to solve this – but, hey, I’m not one of you (but do feel free to suggest far better solutions!). This worked for me and I got done what I needed done and that’s the point. The posts were readable, cutnpaste-able, and I can make beautiful new high-rez versions of the videos and photos.

Then, as this is now running in WordPress in MAMP on my intranet, I can do a really long term save – like printing the bloody things – and also export the data to whatever public-facing blog I want. Of course, it’s still in a MySQL database, but there seem to be easier export options available to me in this day and age – and they conform to my new WordPress standards, which is also a hosted solution as well as a standalone (i.e. I might expect longer term data-migration support.)

This is a process I’ve struggled with since using Blogger in 2002 and onwards: the continual migration of data across different incompatible CMSs. There seems to be no particularly easy way to do it, but such is life.

I hope this gives the few who might come across this problem an approach to attempt doing it yourself – it’s worked for me.

Oh, and so the whole Wolfram Alpha thing: that was a way of figuring out the  “created” dates of the blog posts contained in the old nodes.xml file:

<!-- Table node -->
        <table name="node">
            <column name="nid">1</column>
            <column name="type">blog</column>
            <column name="title">antarcticavirtua.net</column>
            <column name="uid">1</column>
            <column name="status">1</column>
            <column name="created">1123895580</column>
            <column name="changed">1124373591</column>
            <column name="comment">0</column>
            <column name="promote">1</column>
            <column name="moderate">0</column>
            <column name="teaser">Well, here we go. This is my very first blog entry using the Drupal CMS for this research website.

Good luck!

Advertisements
No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: