MT+MySQL·PHP 05b: Exporting and importing weblog posts
Commenting on my previous post, Christine from Big Pink Cookie pointed out that she’d moved a great many client blogs without ever having to run multiple imports. PapaScott (in a comment) and Burningbird in a P-to-P email both suggested copying the Berkeley DB files to the new host, tweaking the database files as suggested in the troubleshooting documentation, and then converting the Berkeley DB to MySQL.
Color me stubborn, but I prefer the export/import method—particularly since both PapaScott and Burningbird flagged the aforesaid troubleshooting procedures.
In the light of these comments, I realize that I should have gone a little more deeply into why I took the export/import route. There were a number of reasons: my obsessive/anal-retentive temperament, an irrational fear of encountering DB compatibility issues, a Dishmatiquey desire to start with squeaky clean MT and database… mainly, though, it was because my StartOver plan (which, I’m gratified to learn, Burningbird has decided to emulate) would be easier to implement on the export (text) file than within the old or the new weblog.
Certainly, when I encountered problems with the import, I could have abandoned my strategy and followed PapaScott and Burningbird’s advice. Except that I’m temperamentally incapable of doing such a thing: the knowledge that I’d transferred corruption from Berkeley DB to MySQL would have festered in the back of my mind until it finally drove me crazy. Better to fix the problem and have done with it.
In any case, as the MT documentation suggests, you can use the export feature to create a local backup of your weblog content (I’d be interested in any feedback on the relative merits of this method versus using MySQL Dump to back up the database).
If you do create an export file as a backup, you may well encounter one or more of the problems I did. Commenting on my duplicated entries and comments, Christine said: “I guess there is a first for everything.” Indeed there is, and if anyone’s going to run into it, odds on it’ll be me. On to the problems and fixes.
Odd characters in titles
I noticed that not only were the entries and comments duplicated, but the entry IDs in the weblog started at 344. In addition, the following two error messages were repeated four times at the bottom of the List & Edit Entries page within MT:
MT::App::CMS=HASH(0x82638b8) Use of uninitialized value in substitution (s///) at lib/MT/Util.pm line 283.
MT::App::CMS=HASH(0x82638b8) Use of uninitialized value in substr at lib/MT/App/CMS.pm line 1312.
A message on the MT forum suggested an answer:
Well, one of the lines in the CMS.pm file talks about entry titles and another talks about imports. Is it possible that you have an odd character in a title of one of the imported entries?
Sure enough, when I checked post 343—which I assumed was triggering the problem—I found that the post title was “Populate or ?”. Removing the “?” stopped the numbering from 344 and also removed the duplicate entries.
Just to be sure, I replaced unescaped double quotations marks in three titles with the correct " character entity.
Multiple dashes in entries
But the MT::App::CMS=HASH(0x82638b8) error message still appeared twice and entries 682 and 472 were at the top of the entry list (with status Draft instead of Publish), ellipses (…) for titles, and empty message bodies.
I went off on a wild goose chase for a while—fixing unescaped < and > and & entities—but to no avail. Finally I emailed Ben Trott for help. As usual, Ben’s suggestion was right on the money:
Usually these warnings occur because of missing entry bodies… are any of your entries (that you imported) missing their main entry texts?
I looked more carefully at what I’ve called the import summary file, which appears in the browser at the end of the import process. It’s a good idea to save this from the browser since it’s useful for debugging any problems with the import. The relevant section read:
Creating new entry ('Taking up arms against evil')... ok (ID 681)
Creating new comment ('Loren')... ok (ID 1241)
Creating new comment ('Michael Granger')... ok (ID 1242)
Creating new comment ('victor echo zulu')... ok (ID 1243)
Creating new comment ('Jonathon Delacour')... ok (ID 1244)
Creating new entry ('')... ok (ID 682)
Creating new comment ('victor echo zulu')... ok (ID 1245)
Creating new entry ('The Tim Tams have landed')... ok (ID 683)
Creating new comment ('Mahesh Shantaram')... ok (ID 1246)
Creating new entry ('The full dishwashing monty')... ok (ID 684)
Note the Creating new entry (‘’)… ok (ID 682) line. When I looked at entries 682 and 472, I noticed a potential problem with comments I’d written myself. Frequently, when visitors comment on one of my posts, I answer multiple comments in a single comment of my own. In these two posts, I’d separated my responses with ten dashes, which Movable Type had read as the trigger for a new post.
I removed each set of ten dashes and the next import went without a hitch.
The moral of the story? Despite the sound design of importing and exporting in Movable Type, things can go wrong. You can minimize problems if you take care to:
- Save the import summary that appears in the browser at the end of the import process.
- Avoid any weird characters in your entry titles.
- Fix any unescaped character entities.
- Remove any erroneous multiple dashes from your entries or comments.

I've always gone with the import/export route too, for the same reasons you've stated (fear of problems with Berkley DB). It helps having your further explaination of what happened to clarify why you had to do it more than once. Thanks for sharing that!
Posted by: Christine on 3 November 2002 at 11:22 AM