In 2014, I migrated the OpenPetra forum from phpBB to Discourse. The reason was that Discourse had a fresh look on the way how forums can be done, it had a nice design, and easy and modern user interface. Here is the post about the details: https://www.pokorra.de/2014/09/migrate-phpbb-forum-to-discourse-using-the-ubuntu-packages-from-packager-io/
Unfortunately, the requirements of Discourse for RAM is quite high, and you cannot just install it inside a shared hosting environment, because it is recommended to be run inside a docker container. It uses technology that I just don’t know very much, with Ruby on Rails and Redis etc.
Then I discovered Flarum, which is written in PHP, but looks as nice and feels as modern as Discourse. It does not have exotic requirements, it just works. It is helpful to have an SSH account, to install the dependencies with composer, but that is available at Hostsharing for my shared hosting anyway.
Flarum is still work in progress, and officially in Beta testing. But you can run your forums in production with the latest Beta already, if you know what you are doing.
So now the issue is, how to migrate your forum from Discourse to Flarum.
At TBits.net, we worked on a migration tool, based on the scripts https://github.com/robrotheram/phpbb_to_flarum, https://github.com/viruxe/phpbb_to_flarum, and https://github.com/Reflic/phpbb_to_flarum.
We did not cover all aspects, but only those issues we needed for our OpenPetra forum.
Things we covered were:
- Format text properly, code, lists, http links, etc.
- convert categories to tags
- keep the users email addresses
We did not cover:
- migration of uploaded content
- we did not convert the user passwords (each user must use the resend password functionality of Flarum)
- and probably more…
So this blog post has the goal to make our script public, and to encourage you to use it and improve it! Pull Requests are welcome, or just fork it and use it as you like!
We started to host the script first at https://github.com/Crusader99/discourse_to_flarum, then at https://github.com/The-CJ/discourse-flarum, and now the official home for the script is:
Of course, in your real life scenario, you will have a database already. But for contributing to this script, we might need a test database, for reproducing specific situations. See my other post for details how to create a test database with dummy data for Discourse!
Setting up Flarum is quite easy if you can access your webspace with SSH and you can run Composer. See the german instructions how to install Flarum inside your Hostsharing account.
If you are working with a virtual machine and CentOS7, this Ansible script might be useful:
You can run the playbook like this (assuming your test server or container has the IP 192.168.122.52, and you can access it as root via SSH and via HTTP):
ansible-playbook flarum.yml -u root -e working_host=192.168.122.52
For running the script discourse_to_flarum.php, you also need a PostgreSQL database inside that container. This Ansible playbook will setup PostgreSQL, and will load the Discourse Backup into the PostgreSQL database. It will also install pgadmin and phpMyAdmin, which helps with debugging of the conversion routines.
You can run the playbook like this:
ansible-playbook migration.yml -u root -e working_host=192.168.122.52
After this, you can access phpMyAdmin on the url http://192.168.122.52/phpMyAdmin/, the user is flarum and the password is flarum. You can access phpPgAdmin on the url http://192.168.122.52/phpPgAdmin/, the user is discourse, and the password is discourse.
And on http://192.168.122.52/, your Flarum forum is running.
Now you can actually run the conversion script:
cd /root/flarummigration composer update cp migrate-example.yaml migrate.yaml # perhaps you need to modify the database credentials in migrate.yaml if you have your own setup # if your prefix is not fl_ for the flarum tables sed -i "s/fl_//g" migrate.yaml php discourse_to_flarum.php
to reset the flarum database for a rerun:
zcat ../flarum.sql.gz | mysql -u flarum flarum -p # vi discourse_flarum.php, or vi migrate.yaml php discourse_to_flarum.php
Here are two screenshots of the sample posts in Discourse and in Flarum after the migration (mind you, some of the BBCodes also don’t work in Discourse…)
So there is probably still quite some work to do. Pull requests are welcome!