# Migre um fórum Vanilla para Discourse

**URL:** https://meta.discourse.org/t/migrate-a-vanilla-forum-to-discourse/27273
**Category:** Sysadmins
**Tags:** how-to
**Created:** [6 Abril , 2015 21:27 UTC](https://meta.discourse.org/t/migrate-a-vanilla-forum-to-discourse/27273 "2015-04-06T21:27:39Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Abdul\_Munim\_Zahid](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/abdul_munim_zahid/32/39786_2.png) [@Abdul\_Munim\_Zahid](https://meta.discourse.org/u/Abdul_Munim_Zahid)
#### Post date: [6 Abril , 2015 21:27 UTC](https://meta.discourse.org/t/migrate-a-vanilla-forum-to-discourse/27273/1 "2015-04-06T21:27:39Z")

</div>

I know there are a lot of posts about importing contents from a vanilla forum, but theres a lack of **comprehensive guide**!

Not everyone can afford to hire a developer to migrate their forums and this is my way of giving back to this community 😄

So here it goes:

**You Need:**

1. Terminal (if mac) or alternative for windows
2. A mind strong enough to understand and follow this guide!
3. Patience
4. A cup of coffee

### Step 1: Getting the Importer file!

Use this addon to get the porter file: [Vanilla Porter Addon](http://vanillaforums.org/addon/porter-core)

This will give you a .gz file. Extract it.  
Now rename the newly extracted file to something short and easy and change the extension to .txt.

> For example: “export\_blabla\_fdata\_20150312\_052004.txt” becomes “export.txt”

**(For clarity in this guide, and less typing, rename it to export.txt.)**

### Step 2: Uploading the Importer file!

Now you need to upload this file to your server: (A lot of people ask me how to do this on Fiverr :o )  
On Terminal (MAC) use this command:

```
scp path/to/exporter.txt root@[IP Address of your droplet]:/var/discourse/shared/standalone

```

Here’s an example:

```
scp user/desktop/exporter.txt root@104.236.198.206:/var/discourse/shared/standalone

```

> Hit enter and then input the root password of your droplet!

Voila, your importer file is now on the server!

For Windows users, you can use [WinSCP](http://winscp.net/eng/download.php) or FileZilla if you already have it. Connect with port 22.

### Step 3: Make sure import file has correct permissions

First SSH into your server

```
ssh root@[ip-address of your server/droplet]

```

It will then ask you the root password. Enter it!

Now that you are in the server.  
Navigate to the place where you uploaded the txt file.  
To do so:  
Run this command:

> cd /var/discourse/shared/standalone/uploads

Now lets assign 666 chmod to the exporter file we just uploaded:

> chmod 666 export.txt

Hit enter and you are done! On to the next step

### Step 4: Setting the mood for some migration 😉

Run these commands:

> cd /var/discourse/  
> ./launcher enter app  
> su discourse  
> cd /var/www/discourse

If you are curious. These commands are just first switching you to the discourse folder, then entering the app, then changing the user to discourse etc. Im sleepy so wont elaborate.

### Step 5: Running the importer script!

> RAILS\_ENV=production ruby script/import\_scripts/vanilla.rb /shared/export.txt

Had you been following this guide correctly and obtained a “correct” export file from the vanilla forum.  
Everything should work out and Congrats!

**You just migrated your forum from Vanilla to Discourse!** Congrats!

Now if you have any questions, Or if you are stuck somewhere; Please feel free to post your issue below! I would try to help!  
If you spot a mistake or wish to suggest an improvement to this course do let me know! (How to turn this into wiki post?)

---

<div class="post-metadata">

### Author: ![saadbinakhlaq](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@saadbinakhlaq](https://meta.discourse.org/u/saadbinakhlaq)
#### Post date: [2 Agosto , 2015 03:15 UTC](https://meta.discourse.org/t/migrate-a-vanilla-forum-to-discourse/27273/2 "2015-08-02T03:15:32Z")

</div>

Hey Abdul,

Thanks for the explanation, but I was trying your process and I am getting CSV parsing error. Do you know how I can get it resolved.

---

<div class="post-metadata">

### Author: ![Don\_Fletcher](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don_fletcher/32/66508_2.png) [@Don\_Fletcher](https://meta.discourse.org/u/Don_Fletcher)
#### Post date: [26 Janeiro , 2017 04:11 UTC](https://meta.discourse.org/t/migrate-a-vanilla-forum-to-discourse/27273/3 "2017-01-26T04:11:54Z")

</div>

So… I’m trying to import a forum from YAF. I’ve passed through vanilla and I’m trying to follow these instructions.  
I’m running on a bitnami dicourse vm (bitnami-discourse-1.5.3-1-r28-linux-ubuntu-14.04-x86\_64).  
I’ve come to step 5 :  
`RAILS_ENV=production ruby script/import_scripts/vanilla.rb /shared/export.txt`

I get the following error:  
`You are running an old version of bundler, please upgrade bundler ASAP, if you are using Discourse docker, rebuild your container.`  
and  
script/import\_scripts/vanilla.rb:82:in `import_users': undefined method `’ for nil:NilClass (NoMethodError)  
from script/import\_scripts/vanilla.rb:19:in `execute' from /opt/bitnami/apps/discourse/htdocs/script/import_scripts/base.rb:45:in `perform’  
from script/import\_scripts/vanilla.rb:254:in `’  
The bundler version installed in the vm is Bundler version 1.10.4

I don’t get the impression that the bundler error is fatal, but the final error is confusing me. any help here would be appreciated.

Update – if I setup an development environment like described here : [Discourse as Your First Rails App | BlogDiscourse](https://blog.discourse.org/2013/04/discourse-as-your-first-rails-app/)  
I stil get the same fatal error …  
script/import\_scripts/vanilla.rb:82:in `import_users': undefined method `’ for nil:NilClass (NoMethodError)  
from script/import\_scripts/vanilla.rb:19:in `execute' from /opt/bitnami/apps/discourse/htdocs/script/import_scripts/base.rb:45:in `perform’  
from script/import\_scripts/vanilla.rb:254:in `’

---

<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: [26 Janeiro , 2017 04:20 UTC](https://meta.discourse.org/t/migrate-a-vanilla-forum-to-discourse/27273/4 "2017-01-26T04:20:41Z")

</div>

That’s an old version of Discourse,and an unsupported configuration.

You should upgrade to a supported os and docker.

---

<div class="post-metadata">

### Author: ![fbjerggaard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fbjerggaard/32/121046_2.png) [@fbjerggaard](https://meta.discourse.org/u/fbjerggaard)
#### Post date: [31 Janeiro , 2017 20:27 UTC](https://meta.discourse.org/t/migrate-a-vanilla-forum-to-discourse/27273/5 "2017-01-31T20:27:18Z")

</div>

It seems like the script doesn’t import users passwords - how would one deal with that?

I don’t really feel like telling all my users to change their passwords so how could this be fixed?

---

<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: [31 Janeiro , 2017 21:39 UTC](https://meta.discourse.org/t/migrate-a-vanilla-forum-to-discourse/27273/6 "2017-01-31T21:39:32Z")

</div>

[Discourse.org](http://Discourse.org) hosting doesn’t import passwords and they don’t seem to have trouble getting clients.

There is a [migrate password plugin](https://meta.discourse.org/t/migrated-password-hashes-support/19512). The vanilla importer doesn’t currently support it. It is not clear whether the plugin will work with vanilla passwords. That said, one importer I wrote worked just fine with the plugin by just putting the password hash in the database as described on the plugin’s README.

---

<div class="post-metadata">

### Author: ![fbjerggaard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fbjerggaard/32/121046_2.png) [@fbjerggaard](https://meta.discourse.org/u/fbjerggaard)
#### Post date: [2 Fevereiro , 2017 18:08 UTC](https://meta.discourse.org/t/migrate-a-vanilla-forum-to-discourse/27273/7 "2017-02-02T18:08:38Z")

</div>

Thanks for the reply. What should i change in the importer script to make it import the passwords to the custom field?

---

<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: [2 Fevereiro , 2017 18:31 UTC](https://meta.discourse.org/t/migrate-a-vanilla-forum-to-discourse/27273/8 "2017-02-02T18:31:48Z")

</div>

Follow the instructions in the migrate password plugin.

---

<div class="post-metadata">

### Author: ![fbjerggaard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fbjerggaard/32/121046_2.png) [@fbjerggaard](https://meta.discourse.org/u/fbjerggaard)
#### Post date: [2 Fevereiro , 2017 23:08 UTC](https://meta.discourse.org/t/migrate-a-vanilla-forum-to-discourse/27273/9 "2017-02-02T23:08:59Z")

</div>

There are only 3 lines of ruby code and no example on how to combine it with the import script which is why I wrote here in case someone else has had a go at it.

I only have very basic ruby skills but the one thing I tried failed miserably.

---

<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: [3 Fevereiro , 2017 00:44 UTC](https://meta.discourse.org/t/migrate-a-vanilla-forum-to-discourse/27273/10 "2017-02-03T00:44:02Z")

</div>

Look at some of the other importers that the plugin supports

---

<div class="post-metadata">

### Author: ![Don\_Fletcher](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don_fletcher/32/66508_2.png) [@Don\_Fletcher](https://meta.discourse.org/u/Don_Fletcher)
#### Post date: [10 Fevereiro , 2017 19:49 UTC](https://meta.discourse.org/t/migrate-a-vanilla-forum-to-discourse/27273/11 "2017-02-10T19:49:40Z")

</div>

Ok.. so I’ve setup the Vagrant development envrionment as per directions on [github](https://github.com/discourse/discourse/blob/master/docs/VAGRANT.md).

I run vagrant ssh  
then  
cd /vagrant/  
then RAILT\_ENV=development ruby script/import\_scripts/vanilla.rb ./export.txt

I get the following output

```
    RAILS_ENV=development ruby script/import_scripts/vanilla.rb ./export_2017-01-19_210405.txt 
loading existing groups...
loading existing users...
loading existing categories...
loading existing posts...
loading existing topics...
parsing file...
reading file...
parsing users...
parsing roles...
parsing user_roles...
parsing ranks...
parsing categories...
parsing discussions...
parsing comments...
parsing conversations...
parsing user_conversations...
parsing conversation_messages...

importing users...
script/import_scripts/vanilla.rb:82:in `import_users': undefined method `[]' for nil:NilClass (NoMethodError)
	from script/import_scripts/vanilla.rb:19:in `execute'
	from /vagrant/script/import_scripts/base.rb:45:in `perform'
	from script/import_scripts/vanilla.rb:254:in `<main>'

```

I’m really stuck as to how to troubleshoot this problem. line 82 of the script is when it is processing users… but the syntax is such that I don’t see what the undefined method is.

---

<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: [10 Fevereiro , 2017 20:02 UTC](https://meta.discourse.org/t/migrate-a-vanilla-forum-to-discourse/27273/12 "2017-02-10T20:02:43Z")

</div>

I don’t see where `@roles` gets defined. Any guess on this @zogstrip?

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [10 Fevereiro , 2017 20:44 UTC](https://meta.discourse.org/t/migrate-a-vanilla-forum-to-discourse/27273/13 "2017-02-10T20:44:30Z")

</div>

“roles” are used in some “invite” code, but I think this is most likely

> <https://github.com/discourse/discourse/blob/main/script/import_scripts/vanilla.rb#L79-L110>

---

<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: [10 Fevereiro , 2017 20:56 UTC](https://meta.discourse.org/t/migrate-a-vanilla-forum-to-discourse/27273/14 "2017-02-10T20:56:05Z")

</div>

That line 82 appears to be where the script is hitting a `nil` value.

---

<div class="post-metadata">

### Author: ![Don\_Fletcher](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don_fletcher/32/66508_2.png) [@Don\_Fletcher](https://meta.discourse.org/u/Don_Fletcher)
#### Post date: [10 Fevereiro , 2017 21:01 UTC](https://meta.discourse.org/t/migrate-a-vanilla-forum-to-discourse/27273/15 "2017-02-10T21:01:52Z")

</div>

Well… line 82 – is searching for “Administrator” – but my data has that group callled “Administrators” – I edited my file changing Administrators to Administrator,  
Also there was no role of Moderator defined.  
So I commented out line 83 and line 104 that deals with importing moderator[s].

This gets me beyond that, and I’m getting an error now on import\_categories…

```
script/import_scripts/vanilla.rb:117:in `import_categories': undefined method `[]' for nil:NilClass (NoMethodError)
	from script/import_scripts/vanilla.rb:20:in `execute'
	from /vagrant/script/import_scripts/base.rb:45:in `perform'
	from script/import_scripts/vanilla.rb:254:in `<main>'

```

So – that error is this line:  
@root\_category\_created\_at = parse\_date(@root\_category[:date\_inserted])  
So … my data doesn’t have create dates for the categories… so.. I took hard coded the date like this…  
`@root_category_created_at = parse_date("2012-11-19 13:39:34")`

That took me passed that issue.

So – does this script drop the tables at the beginning? or if I run it over and over again, am I going to build up duplicate data?

---

<div class="post-metadata">

### Author: ![Don\_Fletcher](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don_fletcher/32/66508_2.png) [@Don\_Fletcher](https://meta.discourse.org/u/Don_Fletcher)
#### Post date: [10 Fevereiro , 2017 21:49 UTC](https://meta.discourse.org/t/migrate-a-vanilla-forum-to-discourse/27273/16 "2017-02-10T21:49:18Z")

</div>

After making those changes… I was able to successfully import the data. I had one error, one of the email addresses was malformed, and the user didn’t import.

QUESTION: if I rerun the script, will I get duplicate data?

---

<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: [10 Fevereiro , 2017 22:33 UTC](https://meta.discourse.org/t/migrate-a-vanilla-forum-to-discourse/27273/17 "2017-02-10T22:33:08Z")

</div>

> [@Don\_Fletcher](#):
>
> QUESTION: if I rerun the script, will I get duplicate data?

No. It will import only what wasn’t there before. This lets you run an import and wait for days and then run it again with a new database to add just the new messages.

---

<div class="post-metadata">

### Author: ![Don\_Fletcher](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don_fletcher/32/66508_2.png) [@Don\_Fletcher](https://meta.discourse.org/u/Don_Fletcher)
#### Post date: [10 Fevereiro , 2017 22:34 UTC](https://meta.discourse.org/t/migrate-a-vanilla-forum-to-discourse/27273/18 "2017-02-10T22:34:43Z")

</div>

Thanks… that is awesome. very helpful.

---

<div class="post-metadata">

### Author: ![SimeonGriggs](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@SimeonGriggs](https://meta.discourse.org/u/SimeonGriggs)
#### Post date: [27 Fevereiro , 2017 08:44 UTC](https://meta.discourse.org/t/migrate-a-vanilla-forum-to-discourse/27273/19 "2017-02-27T08:44:41Z")

</div>

Corrections for the OP:

**Import script:**

Old: `RAILS_ENV=production ruby script/import_scripts/vanilla.rb /shared/export.txt`

Should now be: `RAILS_ENV=production ruby script/import_scripts/vanilla.rb public/uploads/export.txt`

**scp command**

Also those `scp` commands call the file `exporter.txt` when it should be `export.txt`

😃

---

<div class="post-metadata">

### Author: ![SimeonGriggs](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@SimeonGriggs](https://meta.discourse.org/u/SimeonGriggs)
#### Post date: [28 Fevereiro , 2017 06:02 UTC](https://meta.discourse.org/t/migrate-a-vanilla-forum-to-discourse/27273/20 "2017-02-28T06:02:51Z")

</div>

So my current import file has 897169 posts… it appears to get slower as the process goes on. When it was first going it ran at 20,000 items/min. Now it’s down to ~1000/min and getting slower.

I’m wondering if I should be stopping and re-starting the import over and over, or just let it run its course?

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