# Migrar um fórum vBulletin 4 para Discourse

**URL:** https://meta.discourse.org/t/migrate-a-vbulletin-4-forum-to-discourse/54881
**Category:** Sysadmins
**Tags:** how-to
**Created:** [Dezembro 28, 2016, 2:59pm UTC](https://meta.discourse.org/t/migrate-a-vbulletin-4-forum-to-discourse/54881 "2016-12-28T14:59:29Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![enigmaty](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/enigmaty/32/65626_2.png) [@enigmaty](https://meta.discourse.org/u/enigmaty)
#### Post date: [Dezembro 28, 2016, 2:59pm UTC](https://meta.discourse.org/t/migrate-a-vbulletin-4-forum-to-discourse/54881/1 "2016-12-28T14:59:29Z")

</div>

In this tutorial we will learn how to migrate vBulletin forum to :discourse: platform using [vBulletin importer script](https://github.com/discourse/discourse/blob/master/script/import_scripts/vbulletin.rb).

I have tested the script with a big database and the result was very good. The script is well written and maintained.

Let’s get started 🙂

#### What data can be imported?

- Groups
- Users
  - Banned Users =\> Suspended Users

- Forums
  - Each parent and child forum =\> Category and Sub-category

- Topics
  - Sticky Thread =\> Pinned Topic
  - Closed Thread =\> Closed Topic
  - Soft Deleted Thread =\> Not listed Topic
  - Moderated Thread =\> Not listed Topic

- Posts
- PMs
- Attachments
- Avatars (requires embedding into database, see below)
- Permalinks for Topics **(just mapping)**

#### Caveats

- Resuming an incomplete import is fine and updating a previously completed import from a new database snapshot is also working, but any edits to users, categories, posts, topics, … that have already been imported will not be updated.
- Categories that are nested too deep will be flattened by the importer. Be aware.
- `[ul]` `[ol]` and `[li]` support for BBCode is incomplete and will need manual fixing. (This issue will not be fixed by the discourse team. See here: [CommonMark testing started here!](https://meta.discourse.org/t/commonmark-testing-started-here/65121))

* * *

# Export Note

The import script will import avatars, but only if they are included in the database export. Visit `/admincp/avatar.php?do=storage` on your site to enable this before you export the database. (And @pfaffman added this without ever visiting that page himself, so if it works, you might add a note here.)

# Using development environment (recommended)

- Setup your development environment by following the guides for [Ubuntu](https://meta.discourse.org/t/beginners-guide-to-install-discourse-on-ubuntu-for-development/14727) (or use [Vagrant](https://github.com/discourse/discourse/blob/master/docs/VAGRANT.md) if you are on Mac or PC)

- Install MySQL server:

- Install the importer dependencies:

- Export the database dump (from vBulletin server):

- Copy the database to your Discourse server (`scp` or `rsync`). And of course you can gzip it first if it’s a big one.

- Import the database (on Discourse server):

- Clear existing data from your local Discourse instance

- Copy the attachments to your Discourse instance (for the path check your VB4 settings).

- Run the importer and wait until the import is done. You can restart it if it slows down.

- Start your Discourse instance:

- Start Sidekiq and let it do its work. Depending on your forum size this can take time. You can monitor the progress at `http://localhost:3000/sidekiq/queues`

- Perform a backup and upload it to your production server by following this [tutorial](https://meta.discourse.org/t/move-your-discourse-instance-to-a-different-server/15721).

- Congratulations! 🎉

* * *

# Using Docker container

- Setup your production environment by following the [official installation guide](https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md).  
Afterwards go to the Admin section and configure a few settings:

- Prepare the Docker container:

- Install MySQL server:

- Install dependencies

- Export the database dump (from vBulletin server):

- Copy the database to your Discourse server (`scp` or `rsync`). And of course you can gzip it first if it’s a big one.

- Import the database (inside Discourse container):

- Copy the attachments to your Discourse instance (for the path check your VB4 settings).

- Run the importer and wait until the import is done. You can restart it if it slows down.

- Cleaning up:

Congratulations! 🎉

* * *

# vBulletin 3

I have tested the `vbulletin.rb` script with vBulletin 3.8.7 Patch Level 1 with very small data and I got very good results. The script was able to run without any errors and migrate the data successfully. And I can say that the vBulletin script is compatible with vBulletin 3.

---

<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: [Janeiro 25, 2017, 4:41pm UTC](https://meta.discourse.org/t/migrate-a-vbulletin-4-forum-to-discourse/54881/2 "2017-01-25T16:41:33Z")

</div>

The script will now import avatars, but they must be embedded into the database. To do so, I’m told that you visit `/admincp/avatar.php?do=storage` and do something there. It seemed to work for the last client I did an import for.

Hey, @erlend_sh, make this a wiki and I’ll add to it in a few days when I submit a PR for this importer.

---

<div class="post-metadata">

### Author: ![prakarshupmanyu](https://avatars.discourse-cdn.com/v4/letter/p/c68b51/32.png) [@prakarshupmanyu](https://meta.discourse.org/u/prakarshupmanyu)
#### Post date: [Março 12, 2017, 9:32am UTC](https://meta.discourse.org/t/migrate-a-vbulletin-4-forum-to-discourse/54881/7 "2017-03-12T09:32:34Z")

</div>

I was following your guide to import my vBulletin forum to Discourse. I am using a docker container for Discourse. I ran the following command:

> [@enigmaty](#):
>
> su discourse -c ‘bundle install --no-deployment --without test --without development’

I got a long list of errors:

```
sudo: no tty present and no askpass program specified
sudo: no tty present and no askpass program specified
[...]
sudo: no tty present and no askpass program specified
sudo: no tty present and no askpass program specified

Bundler::SudoNotPermittedError: Bundler requires sudo access to install at the moment. Try installing again, granting Bundler sudo access when
prompted, or installing into a different path.
An error occurred while installing rake (11.2.2), and Bundler cannot continue.
Make sure that `gem install rake -v '11.2.2'` succeeds before bundling.

```

I am new to ruby on rails and dockers. I do understand the concept of gems and Bundler.  
What do these errors mean and how can I resolve them?

---

<div class="post-metadata">

### Author: ![prakarshupmanyu](https://avatars.discourse-cdn.com/v4/letter/p/c68b51/32.png) [@prakarshupmanyu](https://meta.discourse.org/u/prakarshupmanyu)
#### Post date: [Março 14, 2017, 10:29pm UTC](https://meta.discourse.org/t/migrate-a-vbulletin-4-forum-to-discourse/54881/9 "2017-03-14T22:29:44Z")

</div>

Ok so basically I had to install all the necessary gems.  
The script worked quite well.

However, I am not able to login with one of the users I created on my vBulletin forum just before importing the database over to discourse.

---

<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: [Março 15, 2017, 12:07am UTC](https://meta.discourse.org/t/migrate-a-vbulletin-4-forum-to-discourse/54881/10 "2017-03-15T00:07:15Z")

</div>

You’ll need to set passwords. The script doesn’t import them (last I looked).

And even if it did, you’d need to install [a plugin](https://meta.discourse.org/t/handling-user-passwords-when-importing-from-another-forum-software/29324) to make them work.

---

<div class="post-metadata">

### Author: ![prakarshupmanyu](https://avatars.discourse-cdn.com/v4/letter/p/c68b51/32.png) [@prakarshupmanyu](https://meta.discourse.org/u/prakarshupmanyu)
#### Post date: [Março 15, 2017, 8:48pm UTC](https://meta.discourse.org/t/migrate-a-vbulletin-4-forum-to-discourse/54881/11 "2017-03-15T20:48:57Z")

</div>

I am planning to write a script that will import the passwords for my case.  
I know the mysql tables I need to consider for vBulletin. What is the table in PostgreSQL for Discourse that stores passwords and is used during login?

---

<div class="post-metadata">

### Author: ![Old\_El\_Paso](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/old_el_paso/32/68218_2.png) [@Old\_El\_Paso](https://meta.discourse.org/u/Old_El_Paso)
#### Post date: [Março 15, 2017, 9:23pm UTC](https://meta.discourse.org/t/migrate-a-vbulletin-4-forum-to-discourse/54881/12 "2017-03-15T21:23:08Z")

</div>

Prakarsh would you be able to share the forum url that you are trying to switch from? The vBulletin one. Will the Discourse one have the same URL?

---

<div class="post-metadata">

### Author: ![prakarshupmanyu](https://avatars.discourse-cdn.com/v4/letter/p/c68b51/32.png) [@prakarshupmanyu](https://meta.discourse.org/u/prakarshupmanyu)
#### Post date: [Março 15, 2017, 10:41pm UTC](https://meta.discourse.org/t/migrate-a-vbulletin-4-forum-to-discourse/54881/13 "2017-03-15T22:41:10Z")

</div>

Yes. Here it is: [Brainstorm](http://neuroimage.usc.edu/forums/)

Our plan is to keep the URL same for now. I cannot say when it will be live. Probably by end of next week if everything goes right 😛

---

<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: [Março 15, 2017, 11:48pm UTC](https://meta.discourse.org/t/migrate-a-vbulletin-4-forum-to-discourse/54881/14 "2017-03-15T23:48:51Z")

</div>

> [@prakarshupmanyu](#):
>
> I am planning to write a script that will import the passwords for my case.

Before you do that, you should read [this topic](https://meta.discourse.org/t/handling-user-passwords-when-importing-from-another-forum-software/29324).

You don’t want to directly touch the Discourse tables. You want a script like [this](https://github.com/discourse/discourse/blob/master/script/import_scripts/vbulletin.rb). When I last used it and tried to import the passwords, it ran really slowly. I’m not sure why, but after reading [this](https://blog.codinghorror.com/password-rules-are-bullshit/) I decided that it’s probably not a bad idea to make people change their passwords.

---

<div class="post-metadata">

### Author: ![prakarshupmanyu](https://avatars.discourse-cdn.com/v4/letter/p/c68b51/32.png) [@prakarshupmanyu](https://meta.discourse.org/u/prakarshupmanyu)
#### Post date: [Março 16, 2017, 4:40am UTC](https://meta.discourse.org/t/migrate-a-vbulletin-4-forum-to-discourse/54881/15 "2017-03-16T04:40:20Z")

</div>

@pfaffman - You mentioned you used import\_pass field in your import script.  
Where exactly do you put the import\_pass field? And how do you use it?  
If you could share it would be great help.

---

<div class="post-metadata">

### Author: ![chrisc](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chrisc/32/119982_2.png) [@chrisc](https://meta.discourse.org/u/chrisc)
#### Post date: [Outubro 12, 2017, 10:58am UTC](https://meta.discourse.org/t/migrate-a-vbulletin-4-forum-to-discourse/54881/16 "2017-10-12T10:58:21Z")

</div>

I have tried using this script but it failed 90% into the import of the users:

```plaintext
su discourse -c 'RAILS_ENV=production ruby script/import_scripts/vbulletin.rb'
root:XXXX@localhost wants vb4
loading existing groups...
loading existing users...
loading existing categories...
loading existing posts...
loading existing topics...

importing groups...
        6 / 19 ( 31.6%) Failed to create group id 7 Moderators: ["Name has already been taken"]
       19 / 19 (100.0%)  
importing users
     2746 / 15319 ( 17.9%) W, [2017-10-12T10:07:05.104837 #3578] WARN -- : Bad date/time value "0000:00:00 00:00:00": mon out of range
W, [2017-10-12T10:07:05.106562 #3578] WARN -- : Bad date/time value "0000:00:00 00:00:00": mon out of range
W, [2017-10-12T10:07:05.107305 #3578] WARN -- : Bad date/time value "0000:00:00 00:00:00": mon out of range
    13901 / 15319 ( 90.7%) script/import_scripts/vbulletin.rb:137:in `strip': invalid byte sequence in UTF-8 (ArgumentError)
        from script/import_scripts/vbulletin.rb:137:in `block (2 levels) in import_users'
        from /var/www/discourse/script/import_scripts/base.rb:226:in `block in create_users'
        from /var/www/discourse/script/import_scripts/base.rb:225:in `each'
        from /var/www/discourse/script/import_scripts/base.rb:225:in `create_users'
        from script/import_scripts/vbulletin.rb:133:in `block in import_users'
        from /var/www/discourse/script/import_scripts/base.rb:784:in `block in batches'
        from /var/www/discourse/script/import_scripts/base.rb:783:in `loop'
        from /var/www/discourse/script/import_scripts/base.rb:783:in `batches'
        from script/import_scripts/vbulletin.rb:117:in `import_users'
        from script/import_scripts/vbulletin.rb:78:in `execute'
        from /var/www/discourse/script/import_scripts/base.rb:45:in `perform'
        from script/import_scripts/vbulletin.rb:902:in `<main>'

```

Anyone have any suggestions regarding how to debug and fix this?

---

<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: [Outubro 12, 2017, 12:08pm UTC](https://meta.discourse.org/t/migrate-a-vbulletin-4-forum-to-discourse/54881/17 "2017-10-12T12:08:01Z")

</div>

You have an encoding problem in your database.

The database claims is using one encoding, but some of the data is encoded some other way. A job I just did had a similar problem. UTF-8 likely does not exist when you started your forum.

This is probably a problem for stack exchange or a database person. It’s not a problem with the importer.

It’s the kind of problem that will take 10 minutes following a recipe that you don’t understand, ten hours looking for that recipe, or 100 hours fixing it by hand.

---

<div class="post-metadata">

### Author: ![chrisc](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chrisc/32/119982_2.png) [@chrisc](https://meta.discourse.org/u/chrisc)
#### Post date: [Outubro 12, 2017, 12:11pm UTC](https://meta.discourse.org/t/migrate-a-vbulletin-4-forum-to-discourse/54881/18 "2017-10-12T12:11:54Z")

</div>

Cheers @pfaffman I was approaching the same conclusion… I started writing up the following before your comment…

It looks like it might be caused by non-ascii characters in usernames, so dumping the usernames into a text file and searching for UTF-8:

```plaintext
echo "select username from user" | mysql -p vb4 | grep --color='auto' -P -n "[^[:ascii:]]"

```

These were the entities this threw up:

```plaintext
’ ´ – é ã Ñ í ó 

```

So I used [this page](https://mothereff.in/html-entities) to generate encoded versions and updated the usernames in the database, for example:

```sql
UPDATE user SET username="&rsquo; &acute; &ndash; &eacute; &atilde; &Ntilde; &iacute; &oacute;" WHERE username="’ ´ – é ã Ñ í ó"

```

But the script still fails:

```plaintext
script/import_scripts/vbulletin.rb:137:in `strip': invalid byte sequence in UTF-8 (ArgumentError)
        from script/import_scripts/vbulletin.rb:137:in `block (2 levels) in import_users'
        from /var/www/discourse/script/import_scripts/base.rb:226:in `block in create_users'
        from /var/www/discourse/script/import_scripts/base.rb:225:in `each'
        from /var/www/discourse/script/import_scripts/base.rb:225:in `create_users'
        from script/import_scripts/vbulletin.rb:133:in `block in import_users'
        from /var/www/discourse/script/import_scripts/base.rb:784:in `block in batches'
        from /var/www/discourse/script/import_scripts/base.rb:783:in `loop'
        from /var/www/discourse/script/import_scripts/base.rb:783:in `batches'
        from script/import_scripts/vbulletin.rb:117:in `import_users'
        from script/import_scripts/vbulletin.rb:78:in `execute'
        from /var/www/discourse/script/import_scripts/base.rb:45:in `perform'
        from script/import_scripts/vbulletin.rb:902:in `<main>'

```

So I then dumped the whole users table into a text file:

```bash
echo "select * from user" | mysql -p vb4 > /tmp/allusers.txt

```

And then tried all the [suggesting in this stackexchange thread](https://stackoverflow.com/questions/3001177/how-do-i-grep-for-all-non-ascii-characters-in-unix) for finding non-ascii characters and none were found, so now to search the whole database for the problem…

When I find a solution I’ll post it here in case it helps others…

---

<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: [Outubro 12, 2017, 12:15pm UTC](https://meta.discourse.org/t/migrate-a-vbulletin-4-forum-to-discourse/54881/19 "2017-10-12T12:15:48Z")

</div>

The problem almost certainly exists in other tables.

You need to figure out what it’s encoded in and fix it.

Or, it could be that for some years it’s in one encoding and other years it’s another.

Best of luck. I was relieved they my client had engineers they solved the problem so I didn’t have to. I may have some notes that I’ll try to find when I get out of bed.

---

<div class="post-metadata">

### Author: ![chrisc](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chrisc/32/119982_2.png) [@chrisc](https://meta.discourse.org/u/chrisc)
#### Post date: [Outubro 12, 2017, 2:05pm UTC](https://meta.discourse.org/t/migrate-a-vbulletin-4-forum-to-discourse/54881/20 "2017-10-12T14:05:20Z")

</div>

The database on the old server was UTF-8 but clearly it has some non-UTF-8 in it, the site has been in use for a long time and has 13k users… so taking care with dumping the old database:

```plaintext
mysqldump -uroot -p database -r dump.sql

```

And trying various methods to check the encoding (thanks to Stackexchange):

```plaintext
file dump.sql 
  dump.sql: ASCII text, with very long lines

apt install uchardet 
uchardet dump.sql
  UTF-8

iconv -f utf-8 -t utf-8 dump.sql > dump.utf-8.sql
  iconv: illegal input sequence at position 29618109

apt install moreutils
isutf8 dump.sql 
  dump.sql: line 2995, char 42, byte 29618109: Expecting bytes in the following ranges: 00..7F C2..F4.

```

And this is a image line:

```plaintext
INSERT INTO `customavatar` VALUES (6355,'ÿØÿà\0^PJFIF\0^A^A\0\0^A\0^A\0\0ÿþ\0;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 75

```

And before I delete the line using `vim` I need to increase the size of the partitions as it is a 1.4G file and I’m running out of space when editing it…

---

<div class="post-metadata">

### Author: ![chrisc](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chrisc/32/119982_2.png) [@chrisc](https://meta.discourse.org/u/chrisc)
#### Post date: [Outubro 14, 2017, 10:32am UTC](https://meta.discourse.org/t/migrate-a-vbulletin-4-forum-to-discourse/54881/21 "2017-10-14T10:32:24Z")

</div>

The problem was a `user` with `&#55357;&#56444;` in the `username` field, once the HTML entities were removed the import script ran, but there were a lot of errors like this:

```plaintext
ERR Error running script (call to f_b06356ba4628144e123b652c99605b873107c9be): @user_script:14: @user_script: 14: -MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error. 

```

Is this something that I should be concerned about and something that I should fix and then redo the import?

---

<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: [Outubro 14, 2017, 12:37pm UTC](https://meta.discourse.org/t/migrate-a-vbulletin-4-forum-to-discourse/54881/22 "2017-10-14T12:37:44Z")

</div>

Are you out of disk space?

---

<div class="post-metadata">

### Author: ![chrisc](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chrisc/32/119982_2.png) [@chrisc](https://meta.discourse.org/u/chrisc)
#### Post date: [Outubro 14, 2017, 12:47pm UTC](https://meta.discourse.org/t/migrate-a-vbulletin-4-forum-to-discourse/54881/23 "2017-10-14T12:47:54Z")

</div>

Yes! I’m now spinning up a new virtual server with a huge amount of disk space, CPUs and RAM and I’m going to start from scratch…

---

<div class="post-metadata">

### Author: ![chrisc](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chrisc/32/119982_2.png) [@chrisc](https://meta.discourse.org/u/chrisc)
#### Post date: [Outubro 14, 2017, 1:46pm UTC](https://meta.discourse.org/t/migrate-a-vbulletin-4-forum-to-discourse/54881/24 "2017-10-14T13:46:35Z")

</div>

By the way, I’m following the instructions above for the Docker version and found that I needed to add an additional step in the container

```bash
echo "discourse ALL = NOPASSWD: ALL" >> /etc/sudoers

```

Before running:

```bash
su discourse -c 'bundle install --no-deployment --without test --without development'

```

In the non-docker instructions above there is this step to delete data from the database before doing the import:

> - Clear existing data from your local Discourse instance
> 
> ```plaintext
> cd ~/discourse
> bundle exec rake db:drop db:create db:migrate
> 
> ```

Was this omitted from the Docker instructions on purpose?

---

<div class="post-metadata">

### Author: ![chrisc](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chrisc/32/119982_2.png) [@chrisc](https://meta.discourse.org/u/chrisc)
#### Post date: [Outubro 14, 2017, 1:53pm UTC](https://meta.discourse.org/t/migrate-a-vbulletin-4-forum-to-discourse/54881/25 "2017-10-14T13:53:16Z")

</div>

There are two, different, vbulletin import scripts, in the docker container:

```bash
cd /var/www/discourse
find ./ -name vbulletin.rb
./script/bulk_import/vbulletin.rb
./script/import_scripts/vbulletin.rb

```

The second one is twice the size of the first one and it is the one I have been using.

[Próxima página](https://meta.discourse.org/t/migrate-a-vbulletin-4-forum-to-discourse/54881.md?page=2)
