# Migrate a FluxBB forum to Discourse

**URL:** https://meta.discourse.org/t/migrate-a-fluxbb-forum-to-discourse/51322
**Category:** Migrating to Discourse
**Tags:** how-to
**Created:** [October 10, 2016, 6:35am UTC](https://meta.discourse.org/t/migrate-a-fluxbb-forum-to-discourse/51322 "2016-10-10T06:35:49Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [October 10, 2016, 6:35am UTC](https://meta.discourse.org/t/migrate-a-fluxbb-forum-to-discourse/51322/1 "2016-10-10T06:35:49Z")

</div>

I created a migration [script](https://github.com/discourse/discourse/blob/main/script/import_scripts/fluxbb.rb) to import FluxBB database into Discourse. Now I’m going to explain how to do the import process in a step-by-step tutorial.

I tested this migration script with FluxBB v1.5.10 (which is current version now)

### What data can be imported?

- Users (including bios/signatures)
- Groups
- Categories  
⚠ Permissions won’t be imported and all categories will be public. Right permissions must be set manually after the import.
- Topics (including sticky/pinned status)
- Posts
- Suspended users

Before starting the migration, set a development environment on your machine (or inside a virtual machine) . See the [OS X](https://meta.discourse.org/t/beginners-guide-to-install-discourse-on-mac-os-x-for-development/15772) or [Ubuntu](https://meta.discourse.org/t/beginners-guide-to-install-discourse-on-ubuntu-for-development/14727) installation guide for development.

Discourse requires Ruby 3.4+. To check your Ruby version enter the command below

```bash
ruby -v

```

* * *

### Mysql

Now we need `mysql2` gem for ruby to connect with our old FluxBB database. Run the below commands to install `libmysqlclient-dev` dependency & `mysql2` gem.

```bash
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install libmysqlclient-dev
gem install mysql2

```

* * *

### _(optional)_ Importing MySQL dump into localhost

To install MySQL client and import mysql dump file (.sql) to your development machine follow the instructions below

```bash
sudo apt-get install mysql-server mysql-client

```

Create MySQL user, grants and table

```plaintext
mysql -u root -p mysql
mysql> CREATE USER 'fluxbb'@'localhost' IDENTIFIED BY 'fluxbb';
Query OK, 0 rows affected (0.00 sec)
.
mysql> CREATE DATABASE fluxbb;
Query OK, 1 row affected (0.01 sec)
.
mysql> GRANT ALL PRIVILEGES ON fluxbb.* TO 'fluxbb'@'localhost';
Query OK, 0 rows affected (0.00 sec)
.
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
.
mysql> exit

```

Import your FluxBB database dump file

```plaintext
mysql -u fluxbb -p fluxbb < myfluxbb.sql

```

* * *

### BBCode to Markdown

The import script handles BBCode to Markdown conversion automatically. No additional gems are needed for this.

* * *

After installing `mysql2`, go to your Discourse installation path and open `Gemfile` to edit.

```bash
cd ~/discourse
sudo nano Gemfile

```

Now insert the line below at the end of the file to add the `mysql2` gem to Discourse.

```plaintext
gem 'mysql2'

```

* * *

Before running the import script, paste these lines one by one into your shell. (use arrow keys to edit the values)

```bash
export FLUXBB_HOST="localhost"
export FLUXBB_DB="fluxbb"
export FLUXBB_USER="root"
export FLUXBB_PW=""
export FLUXBB_PREFIX=""

```

Now it’s time to run the import script. Run the below command to start migration.

```plaintext
RAILS_ENV=production bundle exec ruby script/import_scripts/fluxbb.rb

```

Wait until the import is done. You can restart it if it slows down to a crawl.

After all **congratulations!** Your database successfully migrated from FluxBB to Discourse 👍

Start your Discourse instance:

```plaintext
bundle exec rails server

```

Start Sidekiq and let it do its work:

```plaintext
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 `http://localhost:3000/sidekiq`

Now take a backup from admin page `/admin/backups` and import it in your live Discourse website.

> Last edited by @JammyDodger 2024-05-27T14:54:39Z
> 
> > **Check document**
> >
> > Perform check on document:

---

<div class="post-metadata">

### Author: ![creio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/creio/32/221055_2.png) [@creio](https://meta.discourse.org/u/creio)
#### Post date: [May 18, 2021, 5:44pm UTC](https://meta.discourse.org/t/migrate-a-fluxbb-forum-to-discourse/51322/2 "2021-05-18T17:44:34Z")

</div>

```plaintext
discourse@app-deb10-app:/var/www/discourse$ FLUXBB_HOST="localhost" FLUXBB_DB="flux" FLUXBB_USER="fluxbb" FLUXBB_PW="fluxbb" RAILS_ENV=production bundle exec ruby script/import_scripts/fluxbb.rb 
Loading existing groups...
Loading existing users...
Loading existing categories...
Loading existing posts...
Loading existing topics...

creating groups
Traceback (most recent call last):
	9: from script/import_scripts/fluxbb.rb:262:in `<main>'
	8: from /var/www/discourse/script/import_scripts/base.rb:47:in `perform'
	7: from script/import_scripts/fluxbb.rb:40:in `execute'
	6: from script/import_scripts/fluxbb.rb:50:in `import_groups'
	5: from script/import_scripts/fluxbb.rb:258:in `mysql_query'
	4: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-2.3.2/lib/patches/db/mysql2/alias_method.rb:22:in `query'
	3: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:130:in `query'
	2: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:130:in `handle_interrupt'
	1: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:131:in `block in query'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:131:in `_query': Table 'flux.groups' doesn't exist (Mysql2::Error)

```

---

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [June 18, 2021, 2:21pm UTC](https://meta.discourse.org/t/migrate-a-fluxbb-forum-to-discourse/51322/3 "2021-06-18T14:21:11Z")

</div>

Looks like the tables don’t exist in the mySQL database. I’d check by logging in to the mySQL DB first and seeing what tables are there. You might need to modify the script to get it to work.

---

<div class="post-metadata">

### Author: ![creio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/creio/32/221055_2.png) [@creio](https://meta.discourse.org/u/creio)
#### Post date: [June 22, 2021, 7:29pm UTC](https://meta.discourse.org/t/migrate-a-fluxbb-forum-to-discourse/51322/4 "2021-06-22T19:29:22Z")

</div>

[https://creio.github.io/fluxbb-discourse/](https://creio.github.io/fluxbb-discourse/)

Here, everything step-by-step.

---

<div class="post-metadata">

### Author: ![n1bff](https://avatars.discourse-cdn.com/v4/letter/n/e95f7d/32.png) [@n1bff](https://meta.discourse.org/u/n1bff)
#### Post date: [June 24, 2023, 3:25pm UTC](https://meta.discourse.org/t/migrate-a-fluxbb-forum-to-discourse/51322/5 "2023-06-24T15:25:28Z")

</div>

Is this importer broken in modern Discourse versions?

I am running a Discourse instance installed using the [discourse/docs/INSTALL.md at main · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/main/docs/INSTALL.md) (aka “The only officially supported installs of Discourse”).

I did set up a MariaDB DB inside the Docker container, imported my forum dump there, etc because any other approach is very hard to set up. Everything I did was inside the `cd /var/discourse/ && ./launcher enter app` shell.

Running `bundle exec ruby script/import_scripts/fluxbb.rb bbcode-to-md` fails with:

```plaintext
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/connection_adapters/postgresql_adapter.rb:81:in `rescue in new_client
': We could not find your database: discourse. Which can be found in the database configuration file located at config/database.yml. (ActiveRecord::NoDatabaseError)

```

Running `sudo -u postgres psql discourse` in the same shell logs me into the “`discourse`” database just fine.

---

<div class="post-metadata">

### Author: ![n1bff](https://avatars.discourse-cdn.com/v4/letter/n/e95f7d/32.png) [@n1bff](https://meta.discourse.org/u/n1bff)
#### Post date: [June 24, 2023, 4:23pm UTC](https://meta.discourse.org/t/migrate-a-fluxbb-forum-to-discourse/51322/6 "2023-06-24T16:23:11Z")

</div>

Sorry for the negative assumption, it was simple:

The script is meant to be run with the `discourse` user, not as root in the container which is what I did.

---

<div class="post-metadata">

### Author: ![n1bff](https://avatars.discourse-cdn.com/v4/letter/n/e95f7d/32.png) [@n1bff](https://meta.discourse.org/u/n1bff)
#### Post date: [June 24, 2023, 4:43pm UTC](https://meta.discourse.org/t/migrate-a-fluxbb-forum-to-discourse/51322/7 "2023-06-24T16:43:52Z")

</div>

Apart from some BB codes not being converted this seems to have worked well. Thank you!

[Tests, fixes, and a small (optional) feature to allow a FluxBB config to work by harry-wood · Pull Request #6 · nlalonde/ruby-bbcode-to-md · GitHub](https://github.com/nlalonde/ruby-bbcode-to-md/pull/6) seems to be a nice PR with fixes to the BB code conversion.

---

<div class="post-metadata">

### Author: ![n1bff](https://avatars.discourse-cdn.com/v4/letter/n/e95f7d/32.png) [@n1bff](https://meta.discourse.org/u/n1bff)
#### Post date: [October 18, 2023, 8:27pm UTC](https://meta.discourse.org/t/migrate-a-fluxbb-forum-to-discourse/51322/8 "2023-10-18T20:27:05Z")

</div>

_ **Huge warning** _:

Permissions are ignored by this importer.

**All your forums will be posted as public**.

If you had forums that were set to be only readable by moderators, they will be readable by anyone after you used this importer.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 19, 2023, 9:50am UTC](https://meta.discourse.org/t/migrate-a-fluxbb-forum-to-discourse/51322/9 "2023-10-19T09:50:35Z")

</div>

You can modify the permissions of the categories by hand after import. It’d likely not that big a job to fix them up by hand.

Adding support for importing the permissions is likely a bigger job than doing it by hand.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [October 19, 2023, 10:11am UTC](https://meta.discourse.org/t/migrate-a-fluxbb-forum-to-discourse/51322/10 "2023-10-19T10:11:44Z")

</div>

Thank you for reporting this, I’ve added a warning about this in the guide.
