Want to migrate from Kunena3 to Discourse? Great! Let’s get started.
Note: @tarek’s fine work on this topic was replaced wholesale after @pfaffman made considerable changes to the importer. Do not blame @tarek for mistakes!
What data can be imported?
- Users
- Categories
- Topics & Posts
- Attachments
Prerequisites
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mariadb-server libmysqlclient-dev
sudo gem install mysql2
- Add MySQL to the Gemfile and install it
echo "gem 'mysql2'" >> Gemfile
bundle install
- Create MySQL user, grants and table.
MYSQLPASSWD=mysqlpassword
mysql -u root -p$MYSQLPASSWD <<EOF
CREATE USER 'kunena'@'localhost' IDENTIFIED BY 'kunena';
CREATE DATABASE kunena;
GRANT ALL PRIVILEGES ON kunena . * TO 'kunena'@'localhost';
FLUSH PRIVILEGES;
EOF
- Import your Kunena / Joomla installation
mysql -u kunena -pkunena < mykunena.sql
Readying the Script for the import
Copy and paste these lines into your shell:
export DB_HOST="localhost"
export DB_NAME="kunena"
export DB_USER="kunena"
export DB_PW="kunena"
export KUNENA_PREFIX="jos_" # "iff_" sometimes
export IMAGE_PREFIX="http://EXAMPLE.com/media/kunena/attachments"
export PARENT_FIELD="parent_id" # "parent" in some versions
-
Use and and to edit the
DB
variables appropriately. -
The Kunena tables are prefixed with
jos_
in some cases, and withiff_
in others. If the import script fails for you with an error like “unknown column”, hit the and change theKUNENA_PREFIX
variable toiff_
. If that fails too, you will need to inspect the database tables to see what prefix yours uses. Thisgrep
command will give you a list of tables in the database:grep “CREATE TABLE” mykunena.sql
-
Kunena3 attachments have a URL like this:
Edit that variable too.
- Parent field. In some versions, the
parent_id
field of the category table wasparent
. If you get an error about an “unknown column”, change thePARENT_FIELD
to “parent”.
This is really going to happen!
-
Make sure that neither Discourse nor Sidekiq are running.
-
Clear existing data from your local Discourse instance:
cd ~/discourse
rake db:drop db:create db:migrate
-
Run the import script:
ruby script/import_scripts/kunena3.rb
-
Wait until the import is done. You can restart the process if it slows down to a crawl.
-
Start your Discourse instance:
RAILS_ENV=development 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
- If you want Discourse to copy the images to its own database, in your Discourse settings, enable
download remote images to local
and changedownload remote images max days old
to a sufficiently large value, thenrake posts:rebake
.
- Take backup of the data and upload it to on your production site by following this howto.
@tarek’s known issues (2016-05-05)
If, like us, you had a very old Kunena installation that spanned several generations, then you may run into two problems:
- Users are not properly imported for very old posts
- BBCode makes its way into the posts.
It was very time-consuming, but I hand-fixed these. There is some code in the PHPBB import scripts that addresses BBCode → MD conversion, but I didn’t spend much time on it.
Congratulations! You have successfully migrated your site from Kunena3 to Discourse!