# Migrate a phpBB3 forum to Discourse

**URL:** https://meta.discourse.org/t/migrate-a-phpbb3-forum-to-discourse/30810
**Category:** Migrating to Discourse
**Tags:** how-to
**Created:** [July 5, 2015, 10:02pm UTC](https://meta.discourse.org/t/migrate-a-phpbb3-forum-to-discourse/30810 "2015-07-05T22:02:57Z")
**Posts on this page:** 20
**Page:** 3

<div class="post-metadata">

### Author: ![danmaby](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/danmaby/32/119860_2.png) [@danmaby](https://meta.discourse.org/u/danmaby)
#### Post date: [June 5, 2018, 12:39pm UTC](https://meta.discourse.org/t/migrate-a-phpbb3-forum-to-discourse/30810/357 "2018-06-05T12:39:27Z")

</div>

@gerhard thank you! I really appreciate that, it’s now running but I’m hitting an MySQL connection error. I’m hoping it’s just a credentials issue:

```
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/mysql2-0.5.1/lib/mysql2/client.rb:90:in `connect': Lost connection to MySQL server at 'reading initial communication packet', system error: 0 "Internal error/check (Not system error)" (Mysql2::Error::ConnectionError)

```

---

<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: [June 5, 2018, 7:01pm UTC](https://meta.discourse.org/t/migrate-a-phpbb3-forum-to-discourse/30810/358 "2018-06-05T19:01:58Z")

</div>

That looks more like a can’t-connect-to-the-server issue than a credentials problem. Try entering the IP number for the server running (e.g., a docker container?) rather than localhost.

---

<div class="post-metadata">

### Author: ![danmaby](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/danmaby/32/119860_2.png) [@danmaby](https://meta.discourse.org/u/danmaby)
#### Post date: [June 6, 2018, 6:18pm UTC](https://meta.discourse.org/t/migrate-a-phpbb3-forum-to-discourse/30810/359 "2018-06-06T18:18:54Z")

</div>

@pfaffman yeah I had the wrong port. The import is running now. In fact it’s been running for 26 hours now and it’s only at 45% completion. The database is around 570MB, 25,000 posts, 4,800 topics with 6,500 users. Is this time frame normal?

I’ve stopped the import a few times and rebooted the server, each time the import speeds up for a while then slows right down.

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [June 6, 2018, 6:28pm UTC](https://meta.discourse.org/t/migrate-a-phpbb3-forum-to-discourse/30810/360 "2018-06-06T18:28:06Z")

</div>

That’s too slow. I’d say it shouldn’t take more than 2-3 hours.

> [@gerhard](#):
>
> #### 4.2. Why is the import process so slow?
> 
> Importing is CPU-bound. You should use CPUs with fast single-core speed if you are in a hurry. You get an import speed of about 400–600 posts/minute on a typical DigitalOcean server. Bare metal servers, and probably also your desktop computer, are usually about twice as fast.

On what hardware are you running this? Is the database server on a different system with a slow connection? If so, it might be a better idea to create a database dump and use the MariaDB included in the import container.

---

<div class="post-metadata">

### Author: ![danmaby](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/danmaby/32/119860_2.png) [@danmaby](https://meta.discourse.org/u/danmaby)
#### Post date: [June 6, 2018, 6:53pm UTC](https://meta.discourse.org/t/migrate-a-phpbb3-forum-to-discourse/30810/361 "2018-06-06T18:53:02Z")

</div>

Thanks again @gerhard clearly I’ve got an issue then! The database is coming from a 5 GB, 4 core SiteGround VPS to a 2 GB, 2 core DigitalOcean VPS.

---

<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: [June 6, 2018, 8:02pm UTC](https://meta.discourse.org/t/migrate-a-phpbb3-forum-to-discourse/30810/362 "2018-06-06T20:02:36Z")

</div>

Yeah. If you’re dragging the database from across the internet, it’ll be slow going.

---

<div class="post-metadata">

### Author: ![danmaby](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/danmaby/32/119860_2.png) [@danmaby](https://meta.discourse.org/u/danmaby)
#### Post date: [June 7, 2018, 7:30am UTC](https://meta.discourse.org/t/migrate-a-phpbb3-forum-to-discourse/30810/363 "2018-06-07T07:30:15Z")

</div>

@pfaffman it doesn’t seem to matter how I do this it’s slow going 😕 Its run for 11 more hours now using the MariaDB included in the import container and has only imported an additional 11%. So its now been running a total of 41 hours and completed 56%. The CPU on the 2 GB, 2 core DO server is maxed out. Any other thoughts on why this would be so slow? I’ve rebooted the server several times through this process and it speeds up for a while then drops to a crawl again.

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [June 7, 2018, 8:45am UTC](https://meta.discourse.org/t/migrate-a-phpbb3-forum-to-discourse/30810/364 "2018-06-07T08:45:05Z")

</div>

> [@danmaby](#):
>
> Any other thoughts on why this would be so slow?

It’s really hard to say what’s causing it. From the top of my head:

- You caught a really shitty droplet. That happens sometimes. Creating a new one might help. Also, using a _CPU Optimized Droplet_ is highly recommended for imports.

- Your posts contain lots of images and/or attachments. I think that might cause a slow down.

- And I’m out of ideas for now…

I’d really recommend running the import on your local machine, assuming that your PC is reasonable fast. With docker it’s quite easy and the performance is likely to be a lot better than with cloud servers. If it isn’t than there’s definitely something weird going on.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [June 19, 2018, 8:04pm UTC](https://meta.discourse.org/t/migrate-a-phpbb3-forum-to-discourse/30810/365 "2018-06-19T20:04:20Z")

</div>

I have a last minute question guys. My forum is about to be launched.  
I reorganized my forum categories after an import and I merged a lot of them.  
However I have changed my mind and I’d like to “de-merge” some of them.

I think I could do something like:

1. Remove all the message from the category which a lot of messages from other categories were merged in
2. Import again my phpbb dump, so as it supports incremential import, it should re-import only all the message that were deleted, each in their own category

Would that work? How do I delete my entire main category with all its topics and messages (5000+ topics)?

---

<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: [June 19, 2018, 8:16pm UTC](https://meta.discourse.org/t/migrate-a-phpbb3-forum-to-discourse/30810/366 "2018-06-19T20:16:19Z")

</div>

Deleting the topics doesn’t really delete them, so they won’t get re-imported.

I’m not quite clear what you’re trying to do, but I think your best bet is to just move those topics wherever you want them.

The incremental import doesn’t care what category the topics are in, so the new posts (has the forum remained active on the old site?) will be added to their respective topics.

Or maybe you want to just delete everything and run the whole import again.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [June 19, 2018, 8:37pm UTC](https://meta.discourse.org/t/migrate-a-phpbb3-forum-to-discourse/30810/367 "2018-06-19T20:37:21Z")

</div>

Hi,  
Thank you for your quick reply.

> [@pfaffman](#):
>
> I’m not quite clear what you’re trying to do

On phpbb I had a category A and a category B.  
After my import on Discourse, I had a category A, a category B, then I moved all topics from A and B to a new category C, and I deleted my categories A and B.  
I want to re-create my categories A and B (which is done in seconds), and get back my C topics in their original A and B categories. I can’t do this manually by selecting each topic one by one on hundred topics.  
I don’t want to do this on my whole forum, it’s “just” hundreds of topics on several thousand.

> [@pfaffman](#):
>
> Deleting the topics doesn’t really delete them, so they won’t get re-imported.

Uh… 😭 Even by some rails command? 🤔  
Any risk removing posts from the database directly? The Discourse forum isn’t active yet, no user activity at all.  
After having imported from phpbb, besides configuring stuff, no topics or replies were posted etc.

I also don’t want to do a full re-import because I spent so much time configuring stuff since my import.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [June 19, 2018, 10:32pm UTC](https://meta.discourse.org/t/migrate-a-phpbb3-forum-to-discourse/30810/368 "2018-06-19T22:32:44Z")

</div>

@gerhard I cleaned up a lot of old irrelevant 2-years-ago posts in this topic. You may want to take a peek and see if anything was worth editing into the first post as additional info.

---

<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: [June 19, 2018, 10:46pm UTC](https://meta.discourse.org/t/migrate-a-phpbb3-forum-to-discourse/30810/369 "2018-06-19T22:46:53Z")

</div>

> [@Canapin](#):
>
> Uh… 😭 Even by some rails command? 🤔

Here’s an idea. Leave the stuff in category C and set permissions so no one can see it, and/or delete them.

Then, in Rails, do

```ruby
    PostCustomField.where(name: 'import_id').destroy_all

```

That will delete the custom fields that let the importer know that the posts have been imported and it’ll import them again.

> [@Canapin](#):
>
> I also don’t want to do a full re-import because I spent so much time configuring stuff since my import.

And just what “stuff” is that? If it’s just site settings, you can save them with [GitHub - pfaffman/discourse-settings-uploader: Install a Discourse settings JSON file to a site · GitHub](https://github.com/pfaffman/discourse-settings-uploader). If it’s theme stuff, then it’s not _too_ hard to export it and reload it.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [June 19, 2018, 10:59pm UTC](https://meta.discourse.org/t/migrate-a-phpbb3-forum-to-discourse/30810/370 "2018-06-19T22:59:45Z")

</div>

Woah, thank you so much, I’m going to try that!  
I’d be able to like you more than once, I’ll do it. 🙂

Yes, it is site settings actually, plus some users permissions, changed usernames/emails, etc.  
My import is fairly long, plus I had to do some custom commands in order to remove old bb tags (size and color), bulk move thousands of topics from categories to anothers and update the counts, etc…

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [June 20, 2018, 11:07am UTC](https://meta.discourse.org/t/migrate-a-phpbb3-forum-to-discourse/30810/371 "2018-06-20T11:07:54Z")

</div>

> [@pfaffman](#):
>
> Here’s an idea. Leave the stuff in category C and set permissions so no one can see it, and/or delete them.

Juste wondering about something. Does that mean that i’ll have about 5000 topics deleted but still in the database? What about the permalinks if I import again the topics with the same names?

---

<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: [June 20, 2018, 1:15pm UTC](https://meta.discourse.org/t/migrate-a-phpbb3-forum-to-discourse/30810/372 "2018-06-20T13:15:55Z")

</div>

Yes. They’ll be there. Yes, you’ll want to similarly delete the permalinks.

You could also delete the topics and posts from the rails console. If you want to delete all of them you could use a similar command. I’m not sure what other tables you might need to clean out.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [June 20, 2018, 1:27pm UTC](https://meta.discourse.org/t/migrate-a-phpbb3-forum-to-discourse/30810/373 "2018-06-20T13:27:40Z")

</div>

I might give a try as it’s the simplest solution. Hoping that won’t break things…

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [June 20, 2018, 2:25pm UTC](https://meta.discourse.org/t/migrate-a-phpbb3-forum-to-discourse/30810/374 "2018-06-20T14:25:20Z")

</div>

Uh… I noticed something weird. My backups were about 300 MB before and I noticed that they are now more than 600 MB each.

I’m starting wondering if I didn’t remove some message through rails command a while ago and re-import them again or something like. I don’t remember doing such a thing, but I see no reason to have my backup size doubled… Is there any way to check the total number of messages (including deleted ones)? So I could compare with my phpbb forum number of messages.

edit: nevermind, I used data-explorer and I didn’t see any weird thing. Maybe it was because I had issues with imported images and I had to make a recovery from tombstone, which bringed back a lot of images (currently 300 MB of attached files).

---

<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: [June 20, 2018, 7:13pm UTC](https://meta.discourse.org/t/migrate-a-phpbb3-forum-to-discourse/30810/375 "2018-06-20T19:13:08Z")

</div>

See also [The proper way to completely delete hundred of topics via rails?](https://meta.discourse.org/t/the-proper-way-to-completely-delete-hundred-of-topics-via-rails/90323)

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [June 20, 2018, 7:24pm UTC](https://meta.discourse.org/t/migrate-a-phpbb3-forum-to-discourse/30810/376 "2018-06-20T19:24:43Z")

</div>

Yeah I’ve created this topic to not be too off topic here.

[Previous page](https://meta.discourse.org/t/migrate-a-phpbb3-forum-to-discourse/30810.md?page=2)

[Next page](https://meta.discourse.org/t/migrate-a-phpbb3-forum-to-discourse/30810.md?page=4)
