Cloning/Migrating WordPress Multisite/Network Site to a New Domain

Cloning/Migrating WordPress Multisite/Network Site to a New Domain

I’ve been wanting to try out a new theme for davidseah.com, so I needed to create a duplicate installation. Ordinarily, a plugin like BackupBuddy would help migrate the site with relatively little pain, but it turns out that the ones I tried are not able to handle a WordPress Network. This is the case when a single installation of WordPress is used to manage more than one blog; usually it’s one installation per blog. This site, davidseah.com, is a WP Network with each process blog (e.g. this InfoTech process blog) can have its own theme and set of features. There really is no reason for it other than I thought it might be useful for creating more focused subblogs, but in practice it probably hurts more than it helps.

Anyway, since none of the commercial plugins I tried (BackupBuddy and WPMUDEV Snapshot) worked for me, I needed to perform the migration manually. I wasn’t sure if it could be easily done, but there were two helpful posts that got me through it: Moving WordPress Multisite on the WordPress Codex (which I stupidly read last) and Moving WordPress multisite to a new domain/server. You’ll also want to read Changing the Site URL if the domain name is changing.

Basically you do this:

  1. Make a sqldump of the original database with mysqldump, using the WordPress db credentials in wp-config.php
  2. Archive the wp-content folder with tar, along with anything else you might need in the filesystem
  3. Ftp/sftp from the OLD server to the NEW server, and put the sqldump and tar archive
  4. Install WordPress on the new server, setting up the new WordPress db credentials
  5. Make sure you have some way of accessing the new WordPress database with a tool like PhpMyAdmin, because you will need to change some values if the domain is different!
  6. Make sure you have some way of seeing PHP errors.
  7. Use the mysql command to import the sqldump, using the new db credentials. Optionally use PhpMyAdmin.
  8. Untar the wp-content archive in a _tarballs folder to keep things tidy, and then cp -R (recursive copy) the contents of the themes and plugins folder over to the WordPress install.
  9. Make sure the wp-config.php file has the Multisite enabling commands, otherwise nothing will happen.

Read on for example.

Example

This is an example based on my own recent clone from a CentOS 5-based Plesk-managed server (a Media Temple (dv) 4) to a Digital Ocean Ubuntu 13.10 WordPress test installation.

Let’s say we’re migrating a WordPress Network from oldserver.com to newserver.com. We’ve already installed WordPress on newserver.com in a subdirectory called ‘wordpress’ and the instructions for Giving WordPress Its Own Directory have already been followed. On oldserver.com, we had the WP files in the docroot (no subdirectory install here, and it sucked!)

oldserver.com newserver.com
wp home http://oldserver.com http://newserver.com
wp core http://oldserver.com http://newserver.com/wordpress
username oldusersam newusernell
path to wp /var/www/vhosts/oldserver.com/httpdocs /var/www/wordpress
db_user wpuser123 wordpress
db_pass old1ehhaa1 new1e1123
db_host localhost newserver.com
db_name wp123 wordpress

1. Backup Oldserver

I’m assuming you have privileges to open a shell on both newserver and oldserver, and can run the mysql and tar commands. You might be able to sudo if you can’t elevate to root…this depends on your hosts. It goes without saying that both versions of WordPress are the exact same version.

Let’s make backups and send them to the new server. Connecting directly between hosts is waaaaay faster than downloading/reuploading if you have a huge site.

ssh oldusersam@oldserver.com

cd /var/www/vhosts/oldserver.com/httpdocs

tar cvzf files.tgz wp-content/plugins/* wp-content/themes/* wp-content/uploads/*
mysqldump -u'wpuser123' -p wp123 > dump.sql

sftp newserver.com
[login as newusernell]

sftp> put dump.sql
sftp> put files.tgz
sftp> exit

Now, open a new SSH window and login to newserver.com

ssh newusernell@newserver.com

cd ~newusernell

mkdir _tarballs
mv files.tgz _tarballs

cd _tarballs
tar xvzf files.tgz
cp -R wp-content/* /var/www/wordpress/wp-content

mysql -u'wordpress'@'newserver.com' -p'new1e1123' wordpress < dump.sql

At this point, the basic files and database have been move. However, you will need to make a few edits as detailed in Moving WordPress Multisite and make sure wp-config.php has all those options set correctly and match your original install.

In this example, we're also moving the site to a subdirectory install. This has implications as detailed in Changing the Site URL. because the new installation is in a subdirectory (which has implications for index.php in the root…see Giving WordPress Its Own Directory for more info).

In practice, there are some gotchyas:

  • Differences in the config or version of MySQL and PHP can cause hiccups.
  • Subtle differences in .htaccess files or unsupported featured cause server error 500.
  • Can't find the PHP error log, or forgetting to restart Apache after enabling PHP error logging.
  • Moving to a different domain, which requires editing the databases manually, or use the "functions.php" trick to the options. Note that the option names are misleading: 'siteurl' is actually the "WordPress Address" in the admin panel (where the WP core files are), whereas the 'home' option corresponds to "Site Address". This matters if your core WP files are in a subdirectory, not at the root.
  • Making sure that the Multisite commands in wp-config.php are present and correct (particularly for subdomain versus subdirectory setting).
  • The database wordpress user may not have all privileges for an error-free import of the database. Using PhpMySqlAdmin to handle the db transfer instead of using the command line might work around this, otherwise you'll have to grant the appropriate SUPER privs (also possible with PhpMySqlAdmin)

3 Comments

  1. Philip Davis 10 years ago

    I’ve used the Duplicator plugin to move sites between servers. I’m not sure how well it handles multisite installations, but for single site it is excellent.

  2. deebraa 8 years ago

    Have used series of Duplicator plugins. But i recently start using this wordpress Duplicator plugin by WPADM. Is the best have ever used it save a ton of time you can give it a try.