Migrate a FluxBB forum to 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 (including bios/signatures)
  • Groups
  • Categories
    :warning: 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 or Ubuntu installation guide for development.

Discourse requires Ruby 3.4+. To check your 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 mysql-client

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

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.

cd ~/discourse
sudo nano Gemfile

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

gem 'mysql2'

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.

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 :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개의 좋아요
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 
기존 그룹 로드 중...
기존 사용자 로드 중...
기존 카테고리 로드 중...
기존 게시물 로드 중...
기존 주제 로드 중...

그룹 생성 중
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)

mySQL 데이터베이스에 테이블이 없는 것 같습니다. 먼저 mySQL DB에 로그인하여 어떤 테이블이 있는지 확인해 보세요. 스크립트를 수정해야 작동할 수 있습니다.

2개의 좋아요

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

자, 이제 단계별로 설명하겠습니다.

이 임포터가 최신 Discourse 버전에서 깨진 건가요?

저는 https://github.com/discourse/discourse/blob/main/docs/INSTALL.md에 따라 설치한 Discourse 인스턴스를 실행하고 있습니다. (즉, "Discourse의 공식적으로 지원되는 유일한 설치 방법"입니다.)

Docker 컨테이너 안에 MariaDB를 설정하고 포럼 덤프를 туда 가져오는 등 모든 작업을 수행했습니다. 다른 방법은 설정이 매우 어려워서요. 제가 한 모든 작업은 cd /var/discourse/ && ./launcher enter app 셸 내에서 이루어졌습니다.

bundle exec ruby script/import_scripts/fluxbb.rb bbcode-to-md를 실행하면 다음과 같은 오류가 발생합니다:

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

같은 셸에서 sudo -u postgres psql discourse를 실행하면 discourse 데이터베이스에 정상적으로 로그인됩니다.

부정적인 가정으로 죄송합니다. 사실은 이랬습니다:

스크립트는 discourse 사용자로 실행되도록 되어 있는데, 제가 컨테이너 안에서 root로 실행한 것이 문제였습니다.

일부 BB 코드가 변환되지 않은 점을 제외하면 잘 작동한 것 같습니다. 감사합니다!

Tests, fixes, and a small (optional) feature to allow a FluxBB config to work - Pull Request #6 - nlalonde/ruby-bbcode-to-md - GitHub 은 BB 코드 변환에 대한 수정 사항이 포함된 좋은 PR인 것 같습니다.

중요한 경고:

이 가져오기 프로그램은 권한을 무시합니다.

모든 포럼이 공개 상태로 게시됩니다.

모더레이터만 읽을 수 있도록 설정된 포럼이 있었다면, 이 가져오기 프로그램을 사용한 후에는 누구나 읽을 수 있게 됩니다.

1개의 좋아요

수입 후 범주의 권한을 수동으로 수정할 수 있습니다. 수동으로 수정하는 일은 그렇게 큰 일이 아닐 것입니다.

권한을 가져오도록 지원하는 기능은 수동으로 처리하는 것보다 훨씬 더 큰 작업이 될 가능성이 높습니다.

1개의 좋아요

이 문제를 보고해 주셔서 감사합니다. 가이드에 이에 대한 경고 문구를 추가했습니다.

2개의 좋아요