Use an import script that requires MySQL

You’ll need to modify the script to import the data. The bbpress script imports only posts of a particular type (I likely don’t remember the right wordpress lingo). What kind of WP posts do you want to import? Which are topics and which are posts? Is there something like categories? Those are just a few questions you’ll need to answer by modifying the script. How to do that is beyond the scope of the support you’re likely to get here.

Edit:I’ve retired a few times and gotten closer… Now:

At step 2, mysql -u$MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DATABASE < /backup/yourbackup.sql i get the error bash: /backups/yourstratapropertywordpress.sql: No such file or directory when it does exist (at least, in /var/backups it does)

If I jump ahead and try su discourse -c "bundle exec ruby script/import_scripts/bbpress.rb" anyway, I get the following result:

Loading existing users...
Loading existing categories...
Loading existing posts...
Loading existing topics...
Traceback (most recent call last):
        5: from script/import_scripts/bbpress.rb:512:in `<main>'
        4: from script/import_scripts/bbpress.rb:512:in `new'
        3: from script/import_scripts/bbpress.rb:21:in `initialize'
        2: from script/import_scripts/bbpress.rb:21:in `new'
        1: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:90:in `initialize'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:90:in `connect': Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) (Mysql2::Error::ConnectionError)

Thanks! I will take a look at the DB and the script and see if I can’t accomplish my purposes.

1 Like

Good luck! I wrote at least a couple importers before I “learned” Ruby. If you have an understanding of SQL that could be acquired in an undergraduate course in the mid 1980s, you can likely pull it off. If you write the queries something such that the field names in the resulting data match what the script expect you might be able to change only the SQL.

@pfaffman I’d really appreciate your help here, I’m very stuck

I’m pretty slammed right now and this likely isn’t solved here. Email Jay@literatecomputing.com with a budget and I’ll do my best to come up with a solution.

This seems like your MySQL server is either not running or is not installed properly.

1 Like

Success!

The post type should be post and needs to replace post_type topic. Tags were not brought over nor were the topics’ categories. All my posts were imported as an anonymous user, but it is certainly a decent start!

1 Like

Glad you’re making headway!

Thanks for this clear guide, it was key to my understanding of the import process instead of just blindly copy/pasting commands.

I’m still trying to figure out the fastest way to import a very large Drupal forum, and I still get the impression that things could be optimized in my case to shave off some downtime when I do the final production forum migration run. I may be a bit of a graybeard but I’m not yet totally sold on the whole Docker/containerization paradigm. I’m positive that I read somewhere that there was a Docker bug at some point that was causing massively slower performance of dockerized MySQL instances. On the Docker forum I’m seeing this report, but not sure if it’s still relevant. Also it might not be relevant in my case because I’m running Debian instead of Ubuntu on the host.

Another option might be to install MySQL or MariaDB on the host OS outside of the container?

And without getting into the weeds, what about optimizing the my.cnf with some suggestions from MySQLTuner ? The standard Docker configuration that works across the board for all instances can’t be optimal with its buffer pool instances and key buffer sizes, which make a massive difference on a dedicated production DB.

Hi. Thank you for this solution. I’ve been having the gems issues as you mentioned in your writeup, so I’m really looking forward to making this work. Does this method work to migrate a Wordpress bbpress forum (hosted on DreamPress) to a Discourse instance (hosted on Digital Ocean.)

I’m using Digital Ocean’s Ubuntu-based droplet and the web terminal/console. My first question is what is expected to happen when I run the /var/discourse/launcher stop app /var/discourse/launcher rebuild import? Is the web terminal/console suppose to close. I’ve tried doing it but the import.yml file doesn’t seem to save. It reverts back to its default state.

Also, can someone shed some light on whether I need to run the optional step 2 on my setup?

Thank you much in advance.

PS: I am open to paying someone to do it, but my budget is limited to $200.

Maybe you want to post that in marketplace.

1 Like