Converting Berkeley DB Files To New Version
Question
I'm using the Berkeley DB, and after changing hosts/servers, I'm unable to login because the new server has a different version of Berkeley. How do I convert the database files to the new version?
Answer
Converting the DB files over to the format used by the new library version can be accomplished in several different ways, depending on the Berkeley DB versions involved. The files that need to be converted are all of the files in your db directory whose filenames end in either .db or .idx (the .lock files do not need to be converted).
The following steps require that you have shell access to your server, and imply that you are somewhat familiar with running Unix commands; if this is not the case, you should ask your hosting provider to help you.
Back Up
First, and most important, back up your DB files; you need to create backup copies of all of the files in your db directory. (If you do this by downloading the directory, make sure to transfer it in BINARY mode.)
Use db_upgrade If Available
The easiest way to convert the DB files is to use the db_upgrade program; unfortunately this is not available on every server, but it may be available on yours. To find out, log into your shell account, and type the following at your shell prompt (<db_dir> is the path to your db directory):
$ cd <db_dir>
$ db_upgrade *.db *.idx
If your server has db_upgrade, this will convert all of your DB files over to the new format. If this works, you're done, and you can skip the following steps; Movable Type should now work.
Dump And Reload
If the db_upgrade command does not work (for example, if you get an error saying "command not found"), then you will need to use the following method to convert your data. This method dumps out all of the data from your DB files, then loads it into new versions of those DB files.
Determine Which Program To Use
The program used to dump the contents of your DB files is called either one of two things: db_dump or db_dump185. To determine which program you need to use, first try running the following command in your shell account:
$ cd <db_dir>
$ db_dump author.db
If this command is successful, you will see a screenful of data dumped out. If it is unsuccessful, you will get an error message; in this case, try using the following command:
$ db_dump185 author.db
Again, if the command is successful, you will see a screenful of data. If this also fails, then you will need to contact your hosting provider.
Perform The Dump And Reload
Now that you have determined which db_dump program to use (either db_dump or db_dump185), you can dump all of the data from your old DBM files and load it into new versions of those files. To do that, try the following (substitute db_dump185 instead of db_dump, if necessary):
$ db_dump -f author.db.data author.db
$ mv author.db author.db.old
$ db_load -f author.db.data author.db
$ chmod 666 author.db
You will need to run these four commands for each file in your db directory whose name ends in .db or .idx. After that, you're done, and Movable Type should now work.


