Migrer un forum FluxBB vers Discourse

I created a migration script 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
  • Groups
  • Categories
    :warning: Permissions won’t be imported and all categories will be public. Right permissions must be set manually after the import.
  • Topics
  • Posts
  • Suspended users

Before starting the migration, set a development environment on your machine (or inside a virtual machine) . See the OS X or Ubuntu installation guide for development.

I used 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

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.

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

sudo apt-get install mysql-server-5.5 mysql-client-5.5

Create MySQL user, grants and table

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

mysql -u fluxbb -p fluxbb < myfluxbb.sql

BBcode to Markdown

Discourse uses Markdown while FluxBB use BBCode. So we have to convert bbcodes to markdown in all posts. For that we are going to use the nlalonde/ruby-bbcode-to-md gem. Follow the steps below to install the ruby-bbcode-to-md gem.

cd
git clone https://github.com/nlalonde/ruby-bbcode-to-md.git
cd ruby-bbcode-to-md
gem build ruby-bbcode-to-md.gemspec
gem install ruby-bbcode-to-md-*.gem

After the successful installation of both mysql2 and ruby-bbcode-to-md go to your Discourse installation path and open Gemfile to edit.

cd ~/discourse
sudo nano Gemfile

Now insert the lines below at the end of the file to add mysql2 and ruby-bbcode-to-md gems to Discourse.

gem 'mysql2'
gem 'ruby-bbcode-to-md'

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

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.

bundle exec ruby script/import_scripts/fluxbb.rb bbcode-to-md

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 :thumbsup:

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 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 documentPerform check on document:
12 « J'aime »
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)

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.

2 « J'aime »

https://creio.github.io/fluxbb-discourse/

Here, everything step-by-step.

Cet importateur est-il cassé dans les versions modernes de Discourse ?

J’exécute une instance Discourse installée en utilisant le discourse/docs/INSTALL.md at main · discourse/discourse · GitHub (alias « Les seules installations officiellement prises en charge de Discourse »).

J’ai configuré une base de données MariaDB à l’intérieur du conteneur Docker, j’y ai importé mon dump de forum, etc., car toute autre approche est très difficile à configurer. Tout ce que j’ai fait s’est déroulé dans le shell cd /var/discourse/ &amp;&amp; ./launcher enter app.

L’exécution de bundle exec ruby script/import_scripts/fluxbb.rb bbcode-to-md échoue avec :

/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)

L’exécution de sudo -u postgres psql discourse dans le même shell me connecte à la base de données “discourse” sans problème.

Désolé pour cette supposition négative, c’était simple :

Le script est censé être exécuté avec l’utilisateur discourse, et non en tant que root dans le conteneur, ce que j’ai fait.

À part quelques codes BB qui n’ont pas été convertis, cela semble avoir bien fonctionné. Merci !

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 semble être une bonne PR avec des corrections pour la conversion du code BB.

Avertissement important :

Les autorisations sont ignorées par cet importateur.

Tous vos forums seront publiés comme publics.

Si vous aviez des forums qui n’étaient lisibles que par les modérateurs, ils seront lisibles par n’importe qui après avoir utilisé cet importateur.

1 « J'aime »

Vous pouvez modifier les autorisations des catégories manuellement après l’importation. Ce ne serait probablement pas un travail très important de les corriger manuellement.

L’ajout de la prise en charge de l’importation des autorisations est probablement un travail plus important que de le faire manuellement.

1 « J'aime »

Merci d’avoir signalé cela, j’ai ajouté un avertissement à ce sujet dans le guide.

2 « J'aime »