# Migrare un forum Kunena 3 a Discourse

**URL:** https://meta.discourse.org/t/migrate-a-kunena-3-forum-to-discourse/43776
**Category:** Sysadmins
**Tags:** how-to
**Created:** [6 Maggio 2016, 5:25am UTC](https://meta.discourse.org/t/migrate-a-kunena-3-forum-to-discourse/43776 "2016-05-06T05:25:00Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![tarek](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tarek/32/124831_2.png) [@tarek](https://meta.discourse.org/u/tarek)
#### Post date: [6 Maggio 2016, 5:25am UTC](https://meta.discourse.org/t/migrate-a-kunena-3-forum-to-discourse/43776/1 "2016-05-06T05:25:00Z")

</div>

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

1. Set up Discourse development environment on [OS X](https://meta.discourse.org/t/beginners-guide-to-install-discourse-on-mac-os-x-for-development/15772), [Ubuntu](https://meta.discourse.org/t/beginners-guide-to-install-discourse-on-ubuntu-for-development/14727) or [Windows](https://github.com/discourse/discourse/blob/master/docs/VAGRANT.md).

2. Install MySQL or MariaDB

```bash
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mariadb-server libmysqlclient-dev
sudo gem install mysql2

```

1. Add MySQL to the Gemfile and install it

```bash
echo "gem 'mysql2'" >> Gemfile
bundle install

```

1. Create MySQL user, grants and table.

```bash
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

```

1. Import your Kunena / Joomla installation

```bash
mysql -u kunena -pkunena < mykunena.sql

```

### Readying the Script for the import

Copy and paste these lines into your shell:

```bash
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 with `iff_` in others. If the import script fails for you with an error like “unknown column”, hit the ⬆ and change the `KUNENA_PREFIX` variable to `iff_`. If that fails too, you will need to inspect the database tables to see what prefix yours uses. This `grep` command will give you a list of tables in the database:

- Kunena3 attachments have a URL like this:

Edit that variable too.

- Parent field. In some versions, the `parent_id` field of the category table was `parent`. If you get an error about an “unknown column”, change the `PARENT_FIELD` to “parent”.

## This is really going to happen!

1. Make sure that neither Discourse nor Sidekiq are running.

2. Clear existing data from your local Discourse instance:

```bash
cd ~/discourse
rake db:drop db:create db:migrate

```

1. Run the import script: `ruby script/import_scripts/kunena3.rb`

2. Wait until the import is done. You can restart the process if it slows down to a crawl.

3. Start your Discourse instance: `RAILS_ENV=development bundle exec rails server`

- Start Sidekiq and let it do its work:

```plaintext
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](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 change `download remote images max days old` to a sufficiently large value, then `rake posts:rebake`.

1. Take backup of the data and upload it to on your production site by following [this howto](https://meta.discourse.org/t/move-your-discourse-instance-to-a-different-server/15721).

## @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:

1. Users are not properly imported for very old posts
2. 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! 🎉

---

<div class="post-metadata">

### Author: ![Kohhal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kohhal/32/61548_2.png) [@Kohhal](https://meta.discourse.org/u/Kohhal)
#### Post date: [6 Maggio 2016, 8:23am UTC](https://meta.discourse.org/t/migrate-a-kunena-3-forum-to-discourse/43776/2 "2016-05-06T08:23:08Z")

</div>

Hi Tarek,

Thank you! I will be trying this asap!!!

/Kohhal

---

<div class="post-metadata">

### Author: ![Kohhal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kohhal/32/61548_2.png) [@Kohhal](https://meta.discourse.org/u/Kohhal)
#### Post date: [6 Maggio 2016, 11:17am UTC](https://meta.discourse.org/t/migrate-a-kunena-3-forum-to-discourse/43776/3 "2016-05-06T11:17:15Z")

</div>

> [@tarek](#):
>
> Add MySQL to the Gemfilegem ‘mysql2’

Ok, development environment installed (I had previously been trying the import on a DigitalOcean droplet)

First stumbling block in Step 2, “unknown command mysql2”

---

<div class="post-metadata">

### Author: ![tarek](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tarek/32/124831_2.png) [@tarek](https://meta.discourse.org/u/tarek)
#### Post date: [6 Maggio 2016, 3:06pm UTC](https://meta.discourse.org/t/migrate-a-kunena-3-forum-to-discourse/43776/4 "2016-05-06T15:06:23Z")

</div>

woops. That should read ‘gem install mysql2’ I’ll fix it now. Thank you for testing this!

---

<div class="post-metadata">

### Author: ![tarek](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tarek/32/124831_2.png) [@tarek](https://meta.discourse.org/u/tarek)
#### Post date: [6 Maggio 2016, 3:09pm UTC](https://meta.discourse.org/t/migrate-a-kunena-3-forum-to-discourse/43776/5 "2016-05-06T15:09:11Z")

</div>

I just reread the error. You are supposed to add it to the end of the file. I’ve now given an actual command for this using “echo”. Give it a try and see if it works.

`echo "gem 'mysql2'" >> Gemfile`

---

<div class="post-metadata">

### Author: ![Kohhal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kohhal/32/61548_2.png) [@Kohhal](https://meta.discourse.org/u/Kohhal)
#### Post date: [13 Maggio 2016, 9:59pm UTC](https://meta.discourse.org/t/migrate-a-kunena-3-forum-to-discourse/43776/6 "2016-05-13T21:59:14Z")

</div>

Thanks. I’m on holidays until next week - will test as soon as i return

---

<div class="post-metadata">

### Author: ![Kohhal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kohhal/32/61548_2.png) [@Kohhal](https://meta.discourse.org/u/Kohhal)
#### Post date: [19 Maggio 2016, 1:36pm UTC](https://meta.discourse.org/t/migrate-a-kunena-3-forum-to-discourse/43776/7 "2016-05-19T13:36:57Z")

</div>

> [@tarek](#):
>
> Import your Kunena / Joomla installationmysql -u kunena -p kunena \< mykunena.sql

Getting further, Step 4! - where/how do I need to put the .sql backup in order for this command to work?

---

<div class="post-metadata">

### Author: ![tarek](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tarek/32/124831_2.png) [@tarek](https://meta.discourse.org/u/tarek)
#### Post date: [19 Maggio 2016, 2:11pm UTC](https://meta.discourse.org/t/migrate-a-kunena-3-forum-to-discourse/43776/8 "2016-05-19T14:11:23Z")

</div>

You run the command in the directory of the script. Otherwise, set the location. e.g., if your current directory is /home/kohhal, and the file is at /home/kohhal/mykunena.sql, the command above is correct.

If you are in a separate directory, the command is:

`mysql -u kunena -p kunena < /home/kohhal/mykunena.sql`

---

<div class="post-metadata">

### Author: ![Kohhal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kohhal/32/61548_2.png) [@Kohhal](https://meta.discourse.org/u/Kohhal)
#### Post date: [19 Maggio 2016, 4:24pm UTC](https://meta.discourse.org/t/migrate-a-kunena-3-forum-to-discourse/43776/9 "2016-05-19T16:24:31Z")

</div>

Thanks, found the relevant directory on my machine. Is there a way to see if the sql import worked as I am getting an error on the script now as below but I’m sure the table name is correct :

‘kunena.iff\_users’ doesn’t exist

---

<div class="post-metadata">

### Author: ![tarek](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tarek/32/124831_2.png) [@tarek](https://meta.discourse.org/u/tarek)
#### Post date: [19 Maggio 2016, 5:09pm UTC](https://meta.discourse.org/t/migrate-a-kunena-3-forum-to-discourse/43776/10 "2016-05-19T17:09:59Z")

</div>

Hi Kohhal,

This is relatively basic SQL stuff, so perhaps check a guide, ask on the MySQL IRC channels/forums or web search for answers on this one.

Tarek : )

---

<div class="post-metadata">

### Author: ![Kohhal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kohhal/32/61548_2.png) [@Kohhal](https://meta.discourse.org/u/Kohhal)
#### Post date: [20 Maggio 2016, 10:18am UTC](https://meta.discourse.org/t/migrate-a-kunena-3-forum-to-discourse/43776/11 "2016-05-20T10:18:41Z")

</div>

> [@tarek](#):
>
> edit host, username and password to fit for your MySQL. As above, db, user and pass would all be ‘kunena’

Based on this tutorial, should the host be ‘localhost’ ? I suspect/hope that is why my table is not found…

---

<div class="post-metadata">

### Author: ![frold](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/frold/32/82547_2.png) [@frold](https://meta.discourse.org/u/frold)
#### Post date: [11 Novembre 2017, 1:29pm UTC](https://meta.discourse.org/t/migrate-a-kunena-3-forum-to-discourse/43776/12 "2017-11-11T13:29:16Z")

</div>

How to get the import script?

I came to step “Readying the Script for the import”

But when I go to:

> cd /var/discourse/scripts/  
> ls -ls

I only see

> 4 -rwxr-xr-x 1 root root 150 Nov 11 12:32 docker-gc  
> 4 -rwxr-xr-x 1 root root 1115 Nov 11 12:32 mk\_swapfile

---

<div class="post-metadata">

### Author: ![KevinWorkman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kevinworkman/32/122364_2.png) [@KevinWorkman](https://meta.discourse.org/u/KevinWorkman)
#### Post date: [12 Novembre 2017, 9:28pm UTC](https://meta.discourse.org/t/migrate-a-kunena-3-forum-to-discourse/43776/13 "2017-11-12T21:28:40Z")

</div>

> [@frold](#):
>
> How to get the import script?

I have the same question. I see them on GitHub here: [discourse/script/import\_scripts at main · discourse/discourse · GitHub](https://github.com/discourse/discourse/tree/master/script/import_scripts)

But I don’t see that in my Digital Ocean droplet. I feel pretty dumb, because the guides make this seem simple, so I guess I’m missing something obvious.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [12 Novembre 2017, 10:43pm UTC](https://meta.discourse.org/t/migrate-a-kunena-3-forum-to-discourse/43776/14 "2017-11-12T22:43:33Z")

</div>

Search here for #howto topics for other importers. It’s pretty much the same.

---

<div class="post-metadata">

### Author: ![frold](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/frold/32/82547_2.png) [@frold](https://meta.discourse.org/u/frold)
#### Post date: [12 Novembre 2017, 11:01pm UTC](https://meta.discourse.org/t/migrate-a-kunena-3-forum-to-discourse/43776/15 "2017-11-12T23:01:15Z")

</div>

I did so before asking but I couldnt find it else I wouldnt ask…

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [12 Novembre 2017, 11:04pm UTC](https://meta.discourse.org/t/migrate-a-kunena-3-forum-to-discourse/43776/16 "2017-11-12T23:04:01Z")

</div>

Here’s one [Migrate a vBulletin 4 forum to Discourse](https://meta.discourse.org/t/importing-from-vbulletin-4/54881)

---

<div class="post-metadata">

### Author: ![KevinWorkman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kevinworkman/32/122364_2.png) [@KevinWorkman](https://meta.discourse.org/u/KevinWorkman)
#### Post date: [12 Novembre 2017, 11:41pm UTC](https://meta.discourse.org/t/migrate-a-kunena-3-forum-to-discourse/43776/17 "2017-11-12T23:41:32Z")

</div>

That link tells us to execute this line:

`bundle exec ruby script/import_scripts/vbulletin.rb`

We’re asking how to do that, because we don’t see a `script` directory. We only see a `scripts` directory, and it doesn’t contain the import scripts.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [13 Novembre 2017, 1:13am UTC](https://meta.discourse.org/t/migrate-a-kunena-3-forum-to-discourse/43776/18 "2017-11-13T01:13:25Z")

</div>

Those instructions say to install a development environment. If you had followed them, you’d see the import scripts.

If you want to try with a production docker container, you can enter the container and I think you’ll find it there,but that’s likely to cause other complications.

---

<div class="post-metadata">

### Author: ![KevinWorkman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kevinworkman/32/122364_2.png) [@KevinWorkman](https://meta.discourse.org/u/KevinWorkman)
#### Post date: [13 Novembre 2017, 1:38am UTC](https://meta.discourse.org/t/migrate-a-kunena-3-forum-to-discourse/43776/19 "2017-11-13T01:38:12Z")

</div>

Thanks, I guess entering the container is the step I was missing. If I do that, then I can see the import scripts. Unfortunately I don’t have access to a Ubuntu or OS X machine, so I was really hoping to do this directly in Docker. But now I’m getting a bunch of other errors. Sigh. This was just a weekend experiment, so maybe I’ll just stop pursuing this option.

Thanks for your help. Feel free to delete these messages since they don’t really contribute to the actual conversation.

---

<div class="post-metadata">

### Author: ![pgr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pgr/32/156783_2.png) [@pgr](https://meta.discourse.org/u/pgr)
#### Post date: [23 Gennaio 2018, 12:07pm UTC](https://meta.discourse.org/t/migrate-a-kunena-3-forum-to-discourse/43776/20 "2018-01-23T12:07:56Z")

</div>

Hi all. My question is actually about the thread’s topic, Kunena, not about the vBulletin issue which hijacked this thread 🙂

In the Kunena import script, has anybody tried importing the “Thank yous” that any user can give to other people’s posts? I actually think that’s an important part of the community status of people. It should translate into something in Discourse… badges? hearts? I’m not familiar with Discourse yet.

[Next page](https://meta.discourse.org/t/migrate-a-kunena-3-forum-to-discourse/43776.md?page=2)
