I recently did a bbPress database migration successfully using Discourse’s inbuilt migration script. Now I’m going to share it as a step-by-step tutorial.
Note: This tutorial is for the bbPress plugin, not the legacy standalone version of bbPress.
What data can be imported?
Before starting the migration set a development environment on your machine (or inside a virtual machine) and run the import there instead of inside the docker container. When I tried it inside docker container I got
peer authentication failed issue. So I strongly recommending you that you use a development machine. See the OS X or Ubuntu installation guide for development.
Ubuntu 16.04 LTS amd64 xenial image. I recommending using Ruby version 2.3.0 or above (at least 2.0.0). Because I had some compatability issues when installing
mysql2 with older versions of Ruby.
To check Ruby version enter the command below
Now we need to install the
libmysqlclient-dev dependency in order to be able to use the
sudo apt-get install libmysqlclient-dev
After the successful installation go to your Discourse installation path and open bbPress import script file to edit.
cd /var/discourse sudo nano script/import_scripts/bbpress.rb
In this file you can find the mysql database connection code below
@client = Mysql2::Client.new( host: "localhost", username: "root", database: BB_PRESS_DB, )
By default the database host is
localhost and username is
If you are migrating your database from localhost you don’t need to change these settings (in most cases). You have to change the database name only.
Database name is retrieved from
ENV variable. You can check it in top of the ruby file. So you can set it in
~/discourse/.env file or just edit the name database attribute like below. I prefer second method
@client = Mysql2::Client.new( host: "localhost", username: "root", database: "my_bbpress", )
If you are migrating your database from external server then you have to add password attribute to database settings. I am going to simply add raw password in the Ruby file directly. You may add it in
.env file and use it here like database name. So after password inclusion your mysql database setting should look like below.
@client = Mysql2::Client.new( host: "REMOTE_HOST_NAME", username: "DB_USERNAME", password: "MY_SECURE_PASSWORD", database: "DB_NAME", )
Now save the file and exit. It’s time to run migration script
Run the command below in your discourse installation path.
IMPORT=1 bundle && IMPORT=1 bundle exec ruby script/import_scripts/bbpress.rb
Congratulations! Your database successfully migrated from bbPress to Discourse
Now take a backup from admin page
/admin/backups and import it in your live Discourse website.
After you moved your bbPress forum to Discourse if you are still going to use your WordPress website as primary site and you’d like to connect it with Discourse then install Discourse’s official WordPress plugin.