Migrate a bbPress WordPress plugin forum to Discourse

Thanks for this useful tutorial - worked for me although I have a couple of small issues:

  1. The install process seemed to install postgres 11 and Discourse hosted version support postgres 10, so that’s giving them a bit of a headache!

  2. My imported users don’t seem to be able to log into Discourse with their WordPress credentials - I tried it with my own user account, both with the username and the email address, but neither work. I can log into WordPress fine and the user account is present in Discourse, with the associated forum threads. Something changed with passwords/auth maybe?

Are you using SSO from WordPress?

This requires the migrate password plugin. Did you install that?

3 Likes

Hi Michael,

No, that is the first reference I’ve found to the plugin, so thank you for highlighting it - maybe I missed a step somewhere! Thanks for sharing I will take a closer look tomorrow when my eyes aren’t quite so tired!

Ruth

3 Likes

Hi :wave:

Can user uploaded pictures also be migrated?
The plugin for the user uploads was GD bbPress Attachments

Cheers :beers:

The script appears to import attachments.

https://github.com/discourse/discourse/blob/master/script/import_scripts/bbpress.rb#L280-L283

You need to set a BB_PRESS_ATTACHMENTS_DIR ENV variable with the path to the attachments.

1 Like

The uploads of the bbPress plugin appear to be stored in the /uploads folder of the WordPress installation. The GD bbPress Attachments was used for this. Im not sure which kind of path I should put in the BB_PRESS_ATTACHMENTS_DIR variable. Could you help me here a bit? Should I put the full URL path to the uploads e.g. http://www.example.com/httpdocs/wp-content/uploads/2018/02/picture.png or what else?

I saw that the import script didn’t finish successfully since the import_private_messages step failed. Private messages were not activated in the forum. I removed that step form the script and it fails with the message: table wp_bb_attachments doesn't exist which is true. I can’t find any table for attachments in the database tho. How could that attachments have worked in the first place? :thinking:

The attachments need to be in a directory on the server where you run the import.

If you don’t see the attachment table that the script is looking for It may be that you have used some different means of handling attachments than the script expects. My guess is that they are either in a different table that you haven’t found or that the relative filename is in the posts themselves.

It sounds like you need to another function to import them. If you have a budget I can help. Discourse Migration — Literate Computing, LLC has information about imports. You don’t need full service, it seems, so your cost would be less than suggested there.

Since Discourse always runs in a docker container should this directory be linked into the import container?

Correct. If you’re running the import from a container then you need to put those images somewhere that the can be seen from the container and use that path.

1 Like

One last question. Since you mentioned your import service I checked the site and did some more digging into my database and found where the attachments are stored. One sentence on your page made me worry a bit:

For example, some forums can attach files to a post without mentioning them in the body of the message, the import script identifies attachments by replacing references to them in the message body; when this happens, those un-linked attachments are omitted.

I found that my attachments where stored in the wp_postsmeta table as _wp_attached_file. The post itself which had this attachment linked however does not have a mention of this in the post body. It seems the only link here is the post_id and its meta_id. Does this mean that this is an “un-linked attachment” and will be omitted?

It sounds like it.

And my vbulletin import script, which does handle non-linked attachments, doesn’t look for them in that table, so you’ll need some custom code to deal with that, even after I get around to submitting a PR with my script.

EDIT: and it also means that I think that even if they were linked in-post they still wouldn’t work, since they aren’t where the script expects them in the database.

1 Like

Good news! I don’t know exactly how the import script handles it but it does! After making the files accessible to the import container and digging a bit in the script I found that it works. The only problem I had was that the file name which I tested it on contained an ä and thus some weird encoding shit prevented the script from finding the file actually. After fixing the filename the import worked and the attachment appeared at the post!

Thanks a lot for all the tips! :beers:

1 Like

Awesome! Glad the magic worked for you! (Oh! I and I see now that I was looking at the vBulletin script and not bbPress, hence my confusion. That explains why I couldn’t find the table!)

1 Like

Hi
I got an error after launching the IMPORT bundle exec command:

Using unicorn 5.5.1
Using webmock 3.7.6
Using webpush 1.0.0
Using yaml-lint 0.0.10
Bundle complete! 130 Gemfile dependencies, 214 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Traceback (most recent call last):
        31: from scripts/import_scripts/bbpress.rb:4:in `<main>'
        30: from scripts/import_scripts/bbpress.rb:4:in `require'
        29: from /var/discourse/scripts/import_scripts/base.rb:16:in `<top (required)>'
        28: from /var/discourse/scripts/import_scripts/base.rb:16:in `require_relative'
        27: from /var/discourse/config/environment.rb:7:in `<top (required)>'
        26: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.1/lib/rails/railtie.rb:190:in `method_missing'
        25: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.1/lib/rails/railtie.rb:190:in `public_send'
        24: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.1/lib/rails/application.rb:363:in `initialize!'
        23: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.1/lib/rails/initializable.rb:60:in `run_initializers'
        22: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'
        21: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'
        20: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'
        19: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:347:in `call'
        18: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:347:in `each'
        17: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'
        16: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'
        15: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
        14: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'
        13: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.1/lib/rails/initializable.rb:61:in `block in run_initializers'
        12: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.1/lib/rails/initializable.rb:32:in `run'
        11: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.1/lib/rails/initializable.rb:32:in `instance_exec'
        10: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.1/lib/rails/application/bootstrap.rb:73:in `block in <module:Bootstrap>'
         9: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
         8: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/lazy_load_hooks.rb:51:in `each'
         7: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
         6: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'
         5: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'
         4: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
         3: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/ember-rails-0.18.5/lib/ember/rails/engine.rb:19:in `block in <class:Engine>'
         2: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:59:in `load_missing_constant'
         1: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:16:in `allow_bootsnap_retry'
/home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:60:in `block in load_missing_constant': uninitialized constant Sprockets::Engines (NameError)
        32: from scripts/import_scripts/bbpress.rb:4:in `<main>'
        31: from scripts/import_scripts/bbpress.rb:4:in `require'
        30: from /var/discourse/scripts/import_scripts/base.rb:16:in `<top (required)>'
        29: from /var/discourse/scripts/import_scripts/base.rb:16:in `require_relative'
        28: from /var/discourse/config/environment.rb:7:in `<top (required)>'
        27: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.1/lib/rails/railtie.rb:190:in `method_missing'
        26: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.1/lib/rails/railtie.rb:190:in `public_send'
        25: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.1/lib/rails/application.rb:363:in `initialize!'
        24: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.1/lib/rails/initializable.rb:60:in `run_initializers'
        23: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'
        22: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'
        21: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'
        20: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:347:in `call'
        19: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:347:in `each'
        18: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'
        17: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'
        16: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
        15: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'
        14: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.1/lib/rails/initializable.rb:61:in `block in run_initializers'
        13: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.1/lib/rails/initializable.rb:32:in `run'
        12: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.1/lib/rails/initializable.rb:32:in `instance_exec'
        11: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.1/lib/rails/application/bootstrap.rb:73:in `block in <module:Bootstrap>'
        10: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
         9: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/lazy_load_hooks.rb:51:in `each'
         8: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
         7: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'
         6: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'
         5: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
         4: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/ember-rails-0.18.5/lib/ember/rails/engine.rb:19:in `block in <class:Engine>'
         3: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:58:in `load_missing_constant'
         2: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:79:in `rescue in load_missing_constant'
         1: from /home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:8:in `without_bootsnap_cache'
/home/kenaddams42/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:79:in `block in load_missing_constant': uninitialized constant Sprockets::Engines (NameError)
root@sd-114000:/var/discourse# ~

Any idea please ?
Thank you :wink:

Thanks for this tutorial, @vinothkannans!

I’m stuck modifying bbpress.rb

After running sudo nano script/import_scripts/bbpress.rb it opens the file editor, but when I tray and save, it says there’s no such file or directory:

image

It’s a totally fresh install.

Many thanks,

Jake

In the above guide, I used /var/discourse directory to install the Discourse development environment. If you installed it in a different location then make sure to cd to that directory (’~/discourse’ in most cases) instead of the above before running the sudo nano script/import_scripts/bbpress.rb command.

3 Likes

Hi,

I don’t see “script” path in /var/discourse folder.

  • I tried from DigitalOcean’s new Discourse Marketplace fresh instance.
  • I tried from Discourse Docker official install.

This is what /var/discourse/scripts/ looks like:


Best regards

That’s right.

You’ll need to set up a development environment or follow instructions in other import topics about how you might run the import script inside of a production container.

Finally found How to use the bbpress import script - or any other import script with mysql dependency - developers - Discourse Meta for missing part.

Thanks

1 Like