logo

 [ 22-Jan-2009 ]
Database Copy Utility

Database Copy Utility


Some time ago I encountered a nasty problem when tried to migrate from Firebird 2.0 to 2.1: gbak 2.1 was not able to restore any database I had. After some digging through the Internet I found a few similar claims: link1, link2, link3, link4. The problem was due to character encoding of textual BLOBs, which "was handled wrong by Firebirds prior to 2.1". Although people from Firebird team know how the BLOBs "were handled wrong", and "are being handled right", looks like nobody going to fix the problem. That was a reason why I abandoned the idea of moving to Firebird 2.1 that time.

With time we have encountered server performance problems. Keeping in mind exciting improvements of 2.1 I have decided to make another try. I have chosen harder but more reliable way: by re-creating a new empty database and by copying the data.

I extracted the metadata using IB Expert, corrected the script produced by the tool, split the script by parts, separating tables DDL from indices and other objects. Then I created bare tables in the new database instance. And it was right moment to copy the data. As far as the indices and constraints were not created yet, the task looked easy, but...

All the data copy solutions (fbcopy, etc.) which I tried failed to copy the data because of BLOB character transcoding problems. So to finish the migration I have written a java console utility. That utility managed to copy the data table per table correctly.

Finally I created indices, constraints, views, triggers, and stored procedures and database become functional.

You can download my data copy utility from here. Unpack it and run under jre 1.4:

# /usr/java/j2sdk1.4/bin/java -jar dbcopy.jar_


It will explain how to use it.