Skip to content

Instantly share code, notes, and snippets.

@rmpel
Last active August 25, 2020 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rmpel/293f8bd3b56b040835a5e2269b5b3956 to your computer and use it in GitHub Desktop.
Save rmpel/293f8bd3b56b040835a5e2269b5b3956 to your computer and use it in GitHub Desktop.
Migrate website out of multisite

To migrate a website out of a multisite (Yes, this is WordPress!!!!)

  1. determine site ID (for example: 5)
  2. create a spot where the new website will live (for example: /www/mywebsite.nl/public)
  3. install a new WordPress
cd /www/mywebsite.nl/public ; wp core download
  1. copy theme(s) and plugins
cp -a /www/multisite.nl/public/wp-content/{themes,plugins} /www/mywebsite.nl/public/wp-content/
  1. migrate uploads
cp -a /www/multisite.nl/public/wp-content/blogs.dir/5/files/* /www/mywebsite.nl/public/wp-content/uploads/
# 5 is the site-id
  1. export database of multisite to SQL file, use any tool you like for this. You ONLY NEED tables that start with your prefix followed by the site id (for example: wp_5_) and the users and usermeta tables.
  2. edit the database file and make the following changes a. search and replace {your_prefix}{site_id}_ with just {your_prefix}, so wp_5_ becomes wp_ a. remove records from the users table that contain users that are not allowed in the new site. a. check the registered domain name in the options table, listed with site_url (for example: http://mywebsite.multisite.nl) WARNING do NOT rename the domainname here, that might be a problem.
  3. import the database
  4. rename the domain
cd /www/mywebsite.nl/public ; wp search-replace http://mywebsite.multisite.nl http://mywebsite.nl

This is serialization-safe.

  1. rewrite the old file-paths
cd /www/mywebsite.nl/public 
wp search-replace blogs.dir/5/files uploads
# again; 5 is the site-id
wp search-replace /files /wp-content/uploads 
wp search-replace wp-content/wp-content wp-content 

note: not all replacements here are needed in all cases, these are the replacements I did during my tests to get it all working

  1. Now test your site and fix individual problems :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment