Migrate one site out a multisite.

We where asked to host a site. But then it turned out that site was part of a bigger multisite. So after I got all files & db of the complete site I needed to clean it up and only keep the requested site left.

The quick and dirty steps:

  • Don’t change the DNS until you’re done testing.

Webhosting settings

  • Import all files on the server
  • Import the database and change the db settings in wp-config.php.
  • Locally add the domain to the hosts file So I didn’t need to change urls
  • delete all sites using wp site delete SITE_ID
  • Only keep site 1 (the primary you can’t delete) and site 12 (the site ID I needed)

Rename the tables

  • Rename the site 1 tables in mysql RENAME TABLE `amsterda_db`.`wp_links` TO `amsterda_db`.`wp_BACKUP_links`;
  • Rename the site 12 tables to the normal tables RENAME TABLE `amsterda_db`.`wp_12_links` TO `amsterda_db`.`wp_links`;
  • Make sure you only rename the site tables, don’t rename wp_blogs and other multisite tables

Update the url

  • In wp_blogs delete the record of site 12 and change the name to the new main site in wp_blogs.domain. And rename the url inside wp_site.
  • Also cleanup the wp_blog_versions.
  • In wp-config.php change the constant DOMAIN_CURRENT_SITE
  • Search the database for all mentions of the old mainsite. This is a per case check what should be done.
    Links in posts are probably fine. The old url in the wp_options maybe not.

Permissions and roles

  • In the wp_options table search for wp_user_roles as option_name. If this record is not present. Search it in the wp_BACKUP_options and create the record manually.
  • Permissions are still set for site 12 fix that using wp search-replace wp_12_ wp_ wp_usermeta

Test

  • Test your site. At least test uploads, permalinks, creating/updating pages
  • The normal steps usually when deploying a new site.
  • Think about things that might differ on this inherent setup.

Live

  • switch DNS
  • SSL

After the first week

  • Delete all wp_BACKUP_* tables
  • Check for unneeded plugins
  • Check for unneeded users.
  • Possible you should cleanup the uploads folder of old sites, although there may be links to those uploads.

Of course it would be even better to remove the multisite setup. But I was out of time. And I still would have done these steps first.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.