Documentation

Multisite Tools Addon

The Multisite Tools addon extends WP Migrate DB Pro with WordPress multisite specific functionality, giving you complete control of your multisite network migrations.

Current Features

Future Features

The following is a capability we’re considering adding to the Multisite Tools addon:

  • Push/pull a subsite from one multisite install to another multisite install (current workaround)

Pull a Network Subsite to a Single Site Install

When running a pull migration into a single site, the Multisite Tools addon will inform you if the remote site is a multsite install, and give you the option to “Pull from a specific subsite”. If you check this box, you can choose a specific subsite from the list of available network subsites.

Once you’ve picked a subsite from the list, the target table prefix is automatically set and the list of tables and the Find & Replace rows are also updated to match.

Pull a network subsite to a single site install

WP Migrate DB Pro 2.0

pull from specific subsite

WP Migrate DB Pro 1.x

The list of tables you can select for migration is automatically narrowed down to those specific to the subsite, plus the global users and usermeta tables.

All the other options usually available for a push migration are still enabled, including the Advanced Options, Backup Tables and Media Files, Theme Files, and Plugin Files.

This means that if you have the Media Files or Theme and Plugin Files addons, you no longer need to hunt down the media files, theme files, or plugin files for the subsite and manually transfer them to the single site. Multisite Tools takes care of copying the files to the single site and ensuring all links to them are correct in the newly updated site.

The users migrated to the single site install are only those that are currently a member of the subsite, or are authors of migrated content.

Push a single site install to a network subsite

Similarly, when you run a push migration from a single site to a multisite network, the Multisite Tools addon will inform you if the remote site is a multisite install, and give you the option to “Push to a specific subsite”. If you select a subsite to push to, the target table prefix is automatically set, and the list of tables and the Find & Replace rows are updated to match.

All the other options usually available for a push migration are still enabled, including the Advanced Options, and Backup Tables. If you have the Media Files or Theme and Plugin Files addons installed, Multisite Tools takes care of copying the media, theme and plugin files into the subsite and ensuring all links to them are correct in the newly updated site.

Where possible, the users being pushed into the subsite are matched up with existing users via their username and email address, as long as they are also a member of the subsite already. If there is no match then the user is imported along with their metadata. Either way, the migrated posts and comments are updated to ensure the correct user record is referenced in the subsite.

Push a network subsite to a single site install

The Multisite Tools addon allows you to push a network subsite to a single site install, which is triggered from the multisite network. This functions the same as pulling a network subsite to a single site install, but you run a push migration from the multisite, instead of pulling it into the single site.

Multisite Push a subsite screen

WP Migrate DB Pro 2.0

Push Subsite to Single Site Install

WP Migrate DB Pro 1.x

The users, media, themes, and plugins are migrated and updated in the same way.

Pull a single site install to a network subsite

Similarly, the Multisite Tools addon also allows you to pull a single site install into a network subsite, which is triggered from the multisite network. This functions the same as pushing a single site install to a network subsite, but you pull it into the multisite, instead of pushing it from the single site.

Multisite pull into specific subsite screen

WP Migrate DB Pro 2.0

Pull Single Site Install Into Subsite

WP Migrate DB Pro 1.x

The users, media, themes, and plugins are migrated and updated in the same way.

Great Power, Great Responsibility

You may be thinking, “Finally, I can set up one multisite install for developing all my client sites.” While you certainly can do this easier than ever now, just because you can doesn’t mean you should. Instead, we recommend setting up your development environment to mirror the production environment as closely as possible. So if the site will be a single site install in production, set it up as a single site install in development.

You’re much less likely to run into issues after moving the site to production if the two environments are similar.

Migrate a Subsite Between Multisites

In the future, we intend to add the ability to migrate subsites between multisites with push or pull. However, with the current version of Multisite Tools, there is a way to do it already. You can use a single site as an intermediary, push a subsite into it, then from a different multisite install pull it out as a subsite.

  1. On the source multisite Push the subsite to a single site install
  2. On the target multisite Pull the single site install into an empty subsite

Export Subsite as Single Site Install

When the Multisite Tools addon is installed and activated on a multisite install of WordPress, you will see an “Export a subsite as a single site install” checkbox above the Find & Replace rows when the “Export File” migration option is selected.

Multisite export a subsite checkbox

WP Migrate DB Pro 2.0

Export a subsite as a single site install

WP Migrate DB Pro 1.x

When this new checkbox is checked a new select box is shown for selecting the subsite to export.

Multisite screen showing select box

WP Migrate DB Pro 2.0

MST Enter New Table Name Prefix

WP Migrate DB Pro 1.x

Below the subsite select box, you’ll also see a “New Table Name Prefix” textbox. By default, this textbox shows the multisite’s base table name prefix, but you can change it to match the table name prefix that your single site install will use. In version 2.0 of the plugin, we simplified this process.

When exporting a subsite for a single site install the “Tables” select box will show only the tables that belong to the selected subsite, plus the usermeta and users tables that all subsites use. By default, all the tables are selected for export, but you can select just the tables you need.

Database screen showing all selectable tables

WP Migrate DB Pro 2.0

MST Select Tables

WP Migrate DB Pro 1.x

When you are happy with all the selected options, you can click the Export button to create the SQL file.

Now you can use your preferred MySQL administration tool (e.g. phpMyAdmin, Sequel Pro, the CLI) to import the SQL file and overwrite update the database for a single site install of WordPress with the content and settings from the subsite.

Once the data has been imported into the single site install you can then edit or delete the imported users as required.

How It Works

Each subsite of a multisite network install of WordPress has a unique ID number (often called the blog_id). This number is used in the table name prefix for the tables that are created specifically for the subsite as well as in the keys of various settings.

You can read more about the table structure of a WordPress multisite database in our Ultimate Developer’s Guide to the WordPress Database post.

When the tables for a subsite are exported for use in a single site install they are renamed to remove the blog_id.

For example, if a subsite with blog_id 3 is being exported from a site with base table prefix wp_, the table wp_3_posts will be renamed to wp_posts. If the subsite with blog_id 1 (usually the primary site) is being exported then there is no blog_id to be removed from the table names.

If a new table name prefix is entered for the migration, then the prefix is also changed. So in our example above, if we are using the new table name prefix xyz_, then the table wp_3_posts will be renamed to xyz_posts in the export file.

There are often records in the options and usermeta tables that are subsite specific, hence when those tables are exported for a subsite their keys are updated to work for a single site install and subsite records for other subsites are removed from the exported data.