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.

It appears that the mysql-dep.template.yml has been broken with the Debian base Docker image for Discourse during the past few days:

I describe a workaround in this topic. (Apt-get update fails inside container yarn repo not signed - #5 by pfaffman)

It would be fixed next week.