Migrating a WordPress Multisite Subsite to a standalone WordPress Install

Note: This is an advanced guide and is unsupported. Please proceed with extreme caution, take a backup of content, and understand that there is a high potential of breaking things if you attempt this and Reclaim Hosting does not support this. We offer migration services at reasonable rates for folks that wish to have us do this for them, get in touch if interested!

Migrating a WordPress Multisite subsite can be rather tricky since the site will share much of its code and even some of the database tables with other sites in the network, so it’s not as easy as moving files and a a copy of the database and calling it a day. One option would be a standard WordPress export/import, however that method comes with the caveat that themes, plugins, and settings are not migrated with that process which can often leave the user with a lot of cleanup work to get a site back to working order. This guide will detail how to properly migrate a subsite to a standalone WordPress installation while maintaining all settings, themes, and plugins.

We must start by gathering some data about the install. You’ll want to login to the multisite and determine the Site ID Number for this particular subsite. This can be done by going to Network Admin > Sites and then search for the particular subsite and click Edit. You’ll see the ID number as a URL parameter for that site.

You’ll also want to determine which theme and plugins the site is using so you can just move those particular folders since the plugin and themes folders in a multisite will be shared across all subsites and could contain hundreds. This information is best gathered by accessing the Dashboard of the subsite where you’ll find the active theme under Appearance and the Active plugins under the Plugins > Active menu.

Now that we have gathered that information the next step is to download the content. We won’t need core WordPress files since we can install WordPress on our own in the new standalone install. For the plugins and the theme download them via FTP from the associated wp-content/plugins and wp-content/themes folders.

We will also need all the media uploads. These can be found in either wp-content/blogs.dir/SITEID/files or wp-content/uploads/sites/SITEID so you’ll need that Site ID you got earlier to know which folder to download.

Now we need to grab a copy of the database. In a WordPress Multisite install the database can be quite large as there are a few shared tables and then each subsite has its own set of tables. We’ll need to do two separate exports here to handle both. The first export we want to use our site ID number we got early to find the tables specific to that site which will be suffixed in the table name. Exporting just those tables is easiest done via command line for very large databases:

mysqldump DATABASENAME $(mysql -D DATABASENAME -Bse "SHOW TABLES LIKE 'wp_1689_%'") > database-dump.sql

Replace DATABASENAME above and adjust 1689 to whatever site ID number you have and it will export a SQL file with just that site’s tables.

We also need two shared tables which we can grab from phpMyAdmin, they are wp_users and wp_user_meta. They should show up on the last page of tables for that database and you can select both and click Export to grab a SQL file.

(You could also use the following command via terminal: mysqldump DATABASENAME $(mysql -D DATABASENAME -Bse "SHOW TABLES LIKE 'wp_user%'") > databaseusers-dump.sql

Before we begin uploading everything to the new standalone WordPress install we do need to cleanup that site-specific table database dump. All the table names have the site ID in them but the standalone site won’t use that. We can fix this by simply opening the database dump in a text editor and running a find and replace to find (in my example) wp_1689_ and replace with wp_ and then save the file.

We’re now ready to setup the standalone WordPress install. Start by installing a clean copy of WordPress in the account (it won’t matter what credentials you use because our database will replace them).

Using FTP upload your plugins and themes to the wp-content folder. Also go ahead and upload the site media to wp-content/uploads.

Using phpMyAdmin we need to first delete all existing tables from the standalone WordPress install. Select them and choose Drop

Now import in both of the .sql files you exported, the shared user tables and the site specific ones (that you did the find and replace on).

The final step is to do a search and replace for URL changes since the standalone WordPress install will likely be running under a new domain. This is easily accomplished via terminal under the new account with the following command:

wp search-replace 'old-url' 'new-url'

I like to leave out http and https as well as www or not since you may not be sure which URLs are using them and just use the root domain to replace. Also make sure to back up the database before running this so you can revert if things go wrong! There’s also a good chance the uploads were previously loading from URLs like domain.com/subsite/files/2020/etc and will need to be replaced with newdomain/wp-content/uploads.

wp search-replace 'blogs.dir/SITEID/files' 'uploads'

You may also want to remove any users that were not in the User dashboard of the old site or advise the administrator to remove them. If all goes well this migration should allow a subsite to be moved to a standalone WordPress install.