So, you discovered Discourse and want to know how to migrate from your existing phpBB3 forum?
Great! Then keep on reading. This guide will show you how to use the phpBB3 import script for importing from phpBB 3.0.x and 3.1.x.
Importing from phpBB 3.2 is currently not supported.
What data can be imported?
- Avatars (optional)
- Anonymous users (either as user "system" or as suspended users)
- Password hashes, which can be used with the migratepassword plugin (optional)
- Categories and Forums
- Topics and Posts
- Polls and votes (optional)
- Internal links to topics and posts
- Sticky topics and (global) announcements
- Private Messages (optional)
- Attachments (optional)
- Bookmarks (optional)
Permalinks for imported categories, topics and posts (optional)
1. Importing using Docker container
This is the recommended way for importing content from your phpBB3 forum into Discourse.
1.1. Installing Discourse
Install Discourse by following the official installation guide.
Afterwards it's a good idea to go to the Admin section and configure a few settings:
login_required if imported topics shouldn't be visible to the public
hide_user_profiles_from_public if user profiles shouldn't be visible to the public.
download_remote_images_to_local if you don't want Discourse to download images embedded in posts.
disable_edit_notifications if you enabled
download_remote_images_to_local and don't want your users to get lots of notifications about posts edited by the system user.
- Change the value of
slug_generation_method if most of the topic titles use characters which shouldn't be mapped to ASCII (e.g. Arabic). See this post for more information.
The following steps assume that you installed Discourse on Ubuntu and that you are connected to the machine via SSH or have direct access to the machine's terminal.
1.2. Preparing the Docker container
Copy the container configuration file
import.yml and edit it with your favorite editor.
cp containers/app.yml containers/import.yml
- "templates/import/phpbb3.template.yml" to the list of templates. Afterwards it should look something like this:
## Uncomment these two lines if you wish to add Lets Encrypt (https)
That's it. You can save the file, close the editor and build the container.
/var/discourse/launcher stop app
/var/discourse/launcher rebuild import
Building the container creates an
import directory within the container's shared directory. It looks like this:
1.3. Configuring the importer
You can configure the importer by editing the example
settings.yml file that has been copied into the
The settings file is well documented and comes with sensible defaults, but here are a few tips anyway:
1.3.1. Connecting to a remote database
Change the database
schema if you want to connect to a remote database. Make sure that your MySQL server allows remote connections.
1.3.2. Connecting to internal database
The Docker container comes with a MariaDB server which is compatible with MySQL. You don't need to change any database settings if you are going to use it. All you need is a database dump which you can create in multiple ways. Here are two of them:
Create a database backup in phpBB's Administration Control Panel
Connect to the database host and create a database dump:
# replace the last parameter "phpbb" with the database schema name
mysqldump --user root --password --result-file phpbb_mysql.sql phpbb
Copy the database dump into the
/var/discourse/shared/standalone/import/data/ directory. You need to extract the file if you created a gzip or bzip2 compressed backup and make sure that the file is named
1.3.3. Other settings
- Change the
table_prefix in case your phpBB forum isn't using the default naming for database tables.
- Make sure the
phpbb_base_dir points to
1.4. Copying attachments and images
You can skip this step if you don't want to import attachments, avatars or smilies.
Connect to your phpBB3 host using FTP or SCP and download the following directories into the
Attachments are usually stored in the
files directory. You can make sure by checking the path in the Administration Control Panel.
Avatars are usually stored in the
images/avatars directory. You can make sure by checking the path in the Administration Control Panel.
Smilies are stored in the
import directory should look like this if you downloaded all of those directories:
│ ├── files
│ ├── images
│ │ ├── avatars
│ │ │ ├── gallery
│ │ │ └── upload
│ │ └── smilies
1.5. Executing the import script
Tip: It's a good idea to start the import inside a tmux or screen session so that you can reconnect to the session in case of SSH connection loss.
Let's start the import by entering the Docker container and launching the import script inside the Docker container.
/var/discourse/launcher enter import
import_phpbb3.sh # inside the Docker container
Depending on the size of your forum it's now time for some or
The import script will show you a message like this when it's finished: Done (00h 26min 52sec)
Tip: You can abort the import anytime you want by pressing Ctrl+C
When you restart the import it will continue where it left off.
You can exit and stop the Docker container after the import has finished.
exit # inside the Docker container
/var/discourse/launcher stop import
1.6. Starting Discourse
Let's start the app container and take a look at the imported data.
/var/discourse/launcher start app
Discourse will start and Sidekiq will begin post-processing all the imported posts. This can take a considerate amount of time. You can watch the progress by logging in as admin and visiting
1.7. Clean up
So, you are satisfied with the result of the import and want to free some disk space? The following commands will delete the Docker container used for importing as well as all the files used during the import.
/var/discourse/launcher destroy import
rm -R /var/discourse/shared/standalone/import
1.8. The End
Now it's time to celebrate and enjoy your new Discourse instance!
2. Importing using development environment
The following instructions are for users who want to import using a development environment.
Setup your development environment by following the guides for Ubuntu or Mac OS X.
The following instructions assume that you are using Ubuntu.
Make sure that neither Discourse nor Sidekiq are running.
Install some dependencies:
sudo apt-get update
sudo apt-get install libmysqlclient-dev
echo "gem 'mysql2'" >> Gemfile
echo "gem 'ruby-bbcode-to-md', :github => 'nlalonde/ruby-bbcode-to-md'" >> Gemfile
git checkout Gemfile Gemfile.lock
Configure your import. There's an example settings file at
Start your import (change the path to your settings file if you put your custom settings somewhere else):
ruby phpbb3.rb phpbb3/settings.yml
Wait until the import is done. You can restart it if it slows down to a crawl.
Start your Discourse instance:
bundle exec rails server
Start Sidekiq and let it do its work:
bundle exec sidekiq -q critical,4 -q default,2 -q low
Depending on your forum size this can take a long time. You can monitor the progress at
Here's a list of things that are still missing from the importer (in no particular order) :
- Add support for phpBB 3.2
- Add support for the cakeday plugin
- Imported text that looks like Markdown should be escaped
- Close topics that are closed in phpBB3
- Import unapproved posts as hidden posts
- Import read status for each post and private message
- Import custom profile fields
- Import groups
- Improve the BBCode to Markdown converter (ruby-bbcode-to-md)
- Support custom patterns for internal links to topics and posts (SEO optimized URLs)
- Add support for more database sources: MS SQL Server, Oracle, PostgreSQL
Feel free to start your favorite Ruby IDE and help making the importer even better.
4.1. I have a heavily modified forum. Will the import script still work?
Maybe. It depends on what changes those mods made to the database. You'll have to give it a try.
4.2. Why is the import process so slow?
Importing is CPU-bound. You should use CPUs with fast single-core speed if you are in a hurry. You get an import speed of about 400–600 posts/minute on a typical DigitalOcean server. Bare metal servers, and probably also your desktop computer, are usually about twice as fast.
4.3. I have a large forum with lots of users and posts. How can I minimize the downtime during the import?
You can do incremental imports in order to shorten the downtime.
But be warned: There's a small risk of data loss when you do an incremental import, because existing posts and users aren't updated during incremental imports. You'll lose post edits that occurred between imports as well as changes made to user profiles.
4.4. Can I run the Docker based import on my desktop computer or a staging server?
Of course. You can move your Discourse instance to a different server after the import has finished. Take a look at this How-To for instructions.
4.5. Does the script send any emails during the import?
Sending of emails is disabled during the import and Discourse holds off on sending summary emails to imported users for some time. This can be configured with the site setting
default_email_digest_frequency which defaults to 7 days.
4.6. Which version of Discourse should I use for importing?
It is recommended to always use the
beta channel of Discourse for imports since the import script is being constantly improved. So, make sure that the value of
version is set accordingly in the
import.yml configuration files. Everything should be fine if you followed the official installation guide.
4.7. I enabled the import of passwords. Why can't my users login with their old passwords?
Make sure that you enabled the migratepassword plugin in
app.yml by following the How-To for installing plugins. Also, users won't be able to login with their old password if it's considered insecure. By default Discourse requires a minimum password length of 10 chars (for admins it's 15) and the password must not be on the list of common passwords. But users can always reset their password by clicking the "I forgot my password" link on the login dialog or directly by visiting
4.8. The import was successful, but the user list is empty. What is wrong?
The list of users won't show up right away. It is generated by a background task which is executed by Sidekiq. You'll probably have to wait until all the post-processing of the imported data is finished.
4.9. I have custom smilies in my forum. Are they imported?
Yes. You can map them to Emojis in the settings file, otherwise they'll get imported as images. All the default smilies (except and ) already have an Emoji mapping.