Streamline migrating to WordPress Multisite with MU-Migration

MU_Migration_2_blue
Migrating a standalone WordPress site to a site network (or “multisite”) environment is a tedious and tricky endeavor.

The WordPress Importer works reasonably well for smaller, simpler sites, but leaves room for improvement. It exports content, but not site configuration data such as Widget and Customizer configurations, plugins, and site settings. The Importer also struggles to handle a large amount of content. Third party backup plugins that are compatible with site networks offer another solution, but they often involve slow intermediary “cloud” backup and restore steps, and the reliable solutions are mostly commercial.

A more “complete” approach involves migrating the raw database and files. Essentially, create the new site in the WordPress network admin, then export the standalone site’s database tables (excluding user data) to a .sql file, modify the table prefixes to include the new site’s network ID (ex: wp_ becomes wp_5_), and import the updated .sql script into the site network. Moving user accounts is even more involved, as they are shared across a site network: the standalone site’s user IDs are likely already assigned, and some users may already exist. Manually recreating accounts is often the easiest path, and one is still left to remap all of the user IDs associated with the imported content. We haven’t even touched on moving and updating uploaded media… Now imagine you need to move several sites into a network!

A recent client project where I consolidated five sites into a site network was a tipping point. I developed a smoother way to move single WordPress sites into a ”multisite” network: MU-Migration.

To use MU-Migration:

  1. First, make sure you have WP-CLI up and running on the server.
  2. Install MU-Migration (using WP-CLI 0.23 or newer) by running:
    $ wp package install 10up/mu-migration
  3. Run this command on all sites to be moved:
    $ wp mu-migration export all example-site.zip --themes --plugins --uploads
    Note: The flags --themes, --plugins, and --uploads are optional and, when used, will include the themes, plugins, and uploads folders in the .ZIP package respectively.
  4. Move .ZIP file(s) to your multisite server
  5. Run the following command on your multisite instance:
    $ wp mu-migration import all example-site.zip [--new_url=http://multisite.dev/example]
    Note: The --new_url param is optional and changes the siteurl via a search-and-replace.
  6. Once the import finishes, flush the site cache (e.g. Memcached, Redis, Varnish).
  7. Enjoy!

10up has open sourced MU-Migration on Github. We welcome your suggestions, bug reports, and pull requests.

Leave a Comment

We make web publishing easy. Maybe even fun.