Replicate your bbPress Forum Locally for Development
One part of setting up the YLF forum development server did not run very smoothly: replicating the database. I wanted to get a full version of the current YLF forum with all 20,272 posts by 1214 users. There is no backup or import/export functionality currently built in to bbPress (or available as a plug-in), so I needed to (1) do a database backup and (2) upload the backup to the new local database on my development server.
Export your production database. There are many ways to do this, but the most common is probably the tool “phpMyAdmin”. Most hosting services provide access to phpMyAdmin, and it is also part of the WampServer installation that I use on my local webserver. Since WordPress and bbPress have so much in common, I thought it would be wise to follow the WordPress steps for creating a database backup using phpMyAdmin. In particular, steps 1 through 7 worked just fine.
Step 8 is where I had my first problem. Our bbPress database is too big to be saved to a file, and would get cut off after the first 256 posts. For some reason you can get the full database contents by unchecking “Save as File” in the phpMyAdmin “Export” form. The contents are then displayed in a text area.
Copy it into a text file. I got the idea of pasting the contents of the textarea into a text file from Rex. Since it is a text area with over 10MB of text, it is a little unwieldy, but usable nonetheless.
- CTRL-A to select all in the text area, then wait a minute for this to register.
- CTRL-C to copy all that text, then wait another minute or so.
- CTRL-V in a text editor to paste all the text into the file.
So far, so good. Unfortunately, things didn’t go as well when I used phpMyAdmin on the local server to Import the file. There were several odd syntax errors. After some experimentation I started to suspect the text encoding of the file was off. I had been using Notepad++ (a great free editor). To cut a long story short, I switched to trusty Notepad and when saving the file I specified “UTF encoding” in the Notepad “File Save As” dialog box.
Import the text file into your local database. With the database backed up in a UTF-8 encoded text file, the next step is to fire up phpMyAdmin on the local server, load the bbPress database and go to the “Import” form. Since we have a large database, I needed to take a few extra steps to ensure that phpMyAdmin loaded the file. These are the same steps that you need to take before importing a large WordPress blog, namely, setting the following variables in your “php.ini” file:
upload_max_filesize = 20M
post_max_size = 20M
max_execution_time = 200
max_input_time = 200
Voila. The database contents were imported without any problems.
One small note: If your database had allready been configured by the bbPress install, then you need to go into phpMyAdmin on your local server and delete the existing tables to make way for the tables that will be restored from your backup. Please, please be careful. It would be all too easy to get confused and delete the tables in the wrong phpMyAdmin window, that is, the one on your production database. Bye bye forum.
Posted: August 17th, 2008 under Development.
Tags: bbPress, Database, Intermediate