Migrating a WordPress Multisite installation can be a tricky business. It’s not as straightforward as it is with single site installations, and there are no plugins to help you out.
BackupBuddy is my preferred plugin for migrating single site installations, unfortunately it is not yet fully able to perform the same backup and restore procedure for a multisite installation. What it can do is export a single site from a multisite installation, which might be useful to some, but its not really what we are talking about today. Another plugin you might want to check out is WP Migrate DB Pro which helps you migrate databases from one multisite to another.
In this tutorial, I am assuming that we want to move a site from a local server to the production server. Here are the basic steps you’ll need to follow.
Step 1 – Move Database and Files
The first step is to open your FTP client and upload the files from your computer to the server. Next, on your server set up your database and user, and use phpMyAdmin to import all the database tables.
If you visit your site now it won’t work, we’ve got some more work ahead of us before we’ll be greeted by a fully working multisite installation on our production server.
Step 2 – Modify wp-config.php and .htaccess
Now we need to modify wp-config.php and the .htaccess files to reflect the new location, database name, user and password. This should be quite straightforward. Be careful to replace any instance of the old URL with the new one.
Step 3 – Modify Database Tables
This is the step when most things can go wrong. You need to carefully modify the database to reflect the new location of your site.
We will be doing lots of search and replace actions, and here is the SQL statement I use for these replacements.
Go to table wp_options
In this table, change the fields site_urlΒ Β andΒ home.
Go to table wp_blogs
Replace the domainΒ Β and pathΒ Β fields with the new values.
Go to table wp_site
Replace the domainΒ Β and pathΒ Β fields with the new values.
Go to table wp_sitemeta
Change the site_urlΒ Β field
Searching and Replacing within each Subsite
At this point your site should be loading, however we still have potentially many references to the previous URL in each sub site’s tables. We need to change those through a search and replace procedure.
There are several possible solutions:
- Use the Search and Replace plugin
- Use WP CLI’s search and replace command
Another popular search and replace script (which takes into account the serialized nature of data stored in WordPress tables) is the Search and Replace DB scriptΒ from Interconnectit.
I personally use the Search and Replace plugin and it has always worked fine for me.
Conclusion
That’s it! You should now have a perfect replica of your local multisite installation on your production server.
If you get lost, I’ve found it useful sometimes to set up a new clean MultiSite installation on the same server, and then compare values and files between that new installation and the one I’m trying to migrate. This can help give you a reference that you can use to identify mistakes you might have done in setting up the migrated website.
If you enjoyed this post, make sure to subscribe to WP Mayor’s RSS feed.
14 Responses
Awesome content….Just made my task a lot easier. Thanks!!
Nice steps to solve the migration in multisite… Thanks!
> and there are no plugins to help you out.
Actually, there are several backup/migration plugins that support multisite > multisite, multisite > singlesite, singlesite > multisite
You’re actually right but what I notice is that Duplicator Cloner Migrator is the easiest plugin. follow the link below and it’s for free.
Thanks for the tip about wp-config.php I forgot to change value for:
“define(‘DOMAIN_CURRENT_SITE’, ‘oldsite.com’);”
…to “newsite” and I was going crazy with the error. I searched all over about how to migrate a multi-site and there quite little documentation. The few that mention about the config file do not talk about it very much.
So thank you for your 2 cents π
yo’re right…same thing here. all correct but the config part. I have migrate my database, and everithing else like a normal wp istalation using the interconectit tool but I did not remember about changing the domain current site.
Here I found litte more details about how to get this done:
Actually in WordPress codex there is a small mention about chenging this…but I think nobody see it..
THANKS ALOT, I’m almost there :-), I hope. It seems I only have one problem left – “My sites” won’t show. It seems that there is a “/” missing in the url when try reaching it. I get something like this : – se now “/” between com and wp-admin/network. Any HELP outthere.
THANKS
Any plugin ?
Yes, WP Migrate DB Pro.
Worked great. Thanks! A suggestion for making it even more simple: update the .sql file before importing it, in a text editor and replace the old url’s with the new one simple with find/replace. Worked like a charm for me
That’s true Jacob, WP Migrate Pro is now my favourite tool for moving complete multisites.
You are my hero! I was trying to figure this out on my own first and let’s just say it didn’t work. Missed the wp_blogs table and got caught in a redirect loop.
You’re welcome!
Thanks for this post…very clear and easy to follow. Btw WP Migrate Pro has a nifty search and replace feature which automatically pre-populates the source and destination fields with the appropriate URLs. I’ve used it for moving multisite and it works great!