Migrating from s9y to WordPress

It took me some time to dig into it but finally managed to migrate. Serendipity is a nice blog platform that served me well for 10 years. But I couldn’t find a theme that would suite my needs and be responsive. So I decided to move. Here are the steps I took:

  1. Download the WordPress version 4.1 from 2014 from https://wordpress.org/download/releases/. This might not be necessary but I did it just in case since the migration code I found was from 2012.
  2. Install WordPress.
  3. Head to the s9y-to-wp plugin page on github to check the instructions. I did not follow them by the word as they are written for an even older version of WordPress.
  4. In phpMyAdmin or in CLI run this SQL:

    TRUNCATE `wp_posts`;
    TRUNCATE `wp_postmeta`;
    TRUNCATE `wp_term_relationships`;
    TRUNCATE `wp_term_taxonomy`;
    TRUNCATE `wp_comments`;
    TRUNCATE `wp_commentmeta`;
    DELETE FROM wp_terms WHERE wp_terms.term_id!=1;
  5. Ssh to your server to copy the plugin:

    $ cd /var/www/wp/wp-content/plugins
    $ mkdir serendipity
    $ cd serendipity
    $ wget https://raw.githubusercontent.com/ShakataGaNai/s9y-to-wp/master/serendipity.php

  6. In WordPress Dashboard go to Plugins -> Installed plugins and activate the new plugin.
  7. In WordPress Dashboard go to Tools -> Import and click on Run importer under Serendipity.
  8. Enter the required data and follow the instructions.
    If you run php version < 7 you should be OK. If not, keep reading.

I had to do a couple steps more since the plugin s9y-to-wp uses a deprecated set_magic_quotes_runtime(). At first attempt to migrate I got this error:

Call to undefined function set_magic_quotes_runtime()

Since the function was removed in php7 I followed these instructions to install and switch to php5.6.

  1. Install php5.6
    sudo add-apt-repository ppa:ondrej/php
    sudo apt-get update
    sudo apt-get install php7.0 php5.6 php5.6-mysql php-gettext php5.6-mbstring php-mbstring php7.0-mbstring php-xdebug libapache2-mod-php5.6 libapache2-mod-php7.0
  2. Switch to php5.6
    sudo a2dismod php7.0 ; sudo a2enmod php5.6 ; sudo service apache2 restart

I run the importer again. I didn’t manage to migrate users. I also got a lot of warnings but eventually all posts and comments were migrated.

At the end do not forget to:

  • Upgrade WordPress to the latest version together with plugins, and themes.
  • Switch back to php7
    sudo a2dismod php5.6 ; sudo a2enmod php7.0 ; sudo service apache2 restart

EDIT: While posts have been transferred over without a problem, comments seem not to be linked to the right posts. At least the comments to the same post in the s9y are clustered together under the wrong posts in WP. I’d need to look into this.