Migration eines FluxBB-Forums zu 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 „Gefällt mir“
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 „Gefällt mir“

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

Here, everything step-by-step.

Ist dieser Importer in modernen Discourse-Versionen defekt?

Ich betreibe eine Discourse-Instanz, die gemäß discourse/docs/INSTALL.md at main · discourse/discourse · GitHub (auch bekannt als „Die einzig offiziell unterstützten Installationen von Discourse“) installiert wurde.

Ich habe eine MariaDB-Datenbank innerhalb des Docker-Containers eingerichtet, meinen Foren-Dump dort importiert usw., da jeder andere Ansatz sehr schwer einzurichten ist. Alles, was ich getan habe, geschah innerhalb der Shell cd /var/discourse/ & ./launcher enter app.

Wenn ich bundle exec ruby script/import_scripts/fluxbb.rb bbcode-to-md ausführe, schlägt dies mit folgender Fehlermeldung fehl:

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

Wenn ich sudo -u postgres psql discourse in derselben Shell ausführe, werde ich problemlos in die Datenbank „discourse“ eingeloggt.

Entschuldigen Sie die negative Annahme, es war einfach:

Das Skript soll mit dem discourse-Benutzer ausgeführt werden, nicht als Root im Container, was ich getan habe.

Bis auf einige nicht konvertierte BB-Codes scheint dies gut funktioniert zu haben. Danke!

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 scheint ein guter PR mit Korrekturen zur BB-Code-Konvertierung zu sein.

Riesige Warnung:

Berechtigungen werden von diesem Importeur ignoriert.

Alle Ihre Foren werden als öffentlich gepostet.

Wenn Sie Foren hatten, die nur für Moderatoren lesbar waren, sind diese nach der Verwendung dieses Importeurs für jeden lesbar.

1 „Gefällt mir“

Sie können die Berechtigungen der Kategorien nach dem Import von Hand ändern. Es wäre wahrscheinlich keine große Aufgabe, sie von Hand zu korrigieren.

Das Hinzufügen der Unterstützung für den Import der Berechtigungen ist wahrscheinlich eine größere Aufgabe als die manuelle Korrektur.

1 „Gefällt mir“

Vielen Dank für Ihre Meldung, ich habe eine Warnung dazu in den Leitfaden aufgenommen.

2 „Gefällt mir“