I’ve normally blogged about Perl goodies, but here I am diverting my efforts into my adventures in WordPress. So here goes : How I migrated a Multi-Site/Network WordPress install into individual sites without a migration plugin.
- Backup your multi-site installation using UpdraftPlus. – 5 stars from 2,815 people 1+ Million Active Installations, so good. I’m not affiliated to them – yet! The backup files are in gzip and zip format, so not proprietary as I write this.
- Copy the backup files to your Ubuntu 16.04 PC.
- Install LAMP and a Multi-Site WordPress install on your Ubuntu computer.
- Restore from the backup.
- Use the open-source utility called wp mu-migration which separates the individual sites into a zip file each.
- Install individual WordPress sites on Apache Virtual Hosts on your Ubuntu.
- Use wp mu-migration to insert just the single site (the zip file) into each Virtual Host. Et Voila!
- Do a backup with UpdraftPlus, copy the backup files to your hosting provider, create new WordPress installations and then do a restore of each site.
Here are some of the details I made note of, which are by no means complete, as it took several iterations to get there, but get there I did. I do recommend having SSH access to your hosting provider, as it makes it that bit easier, worth paying for I suggest.
Install Apache and MySQL on Ubuntu 16.04
- I didn’t do the “Adjust the Firewall to Allow Web Traffic” section.
- I did do the
mysql_secure_installationthing. And said Yes to everything.
- I didn’t install php-cli
Install WordPress on Ubuntu 16.04
I did all of this plus :
- Add this to
define( 'WP_ALLOW_MULTISITE', true );
- Save Permalinks twice for some reason I can’t quite remember – do this on all migrated sites.
- Keep the WordPress files for copying to individual site Apache Virtual Host directories.
- Install UpdraftPlus plugin and do a backup.
- Copy the original live site’s UpdraftPlus backup files to the
sudo cp -rvpa backup* /var/www/html/wp-content/updraft/
- Unzip and edit the database file :
sudo gzip -d backup....gz
sudo vi backup_...-db
- Change the domain names to caesuramedia.org, change the database name to ‘wordpress’ and change the refs to the docroot directory (ie
public_html/...) to the caesuramedia.org ones –
sudo gzip backup_...-db
- Attempt a restore using UpdraftPlus – you may have to do this a few times (delete the whole site, copy the WP files, set it up again, etc, etc) until the database all points to caesuramedia.org and all the pics and links work ok.
- When you have a proper copy of the Multi-Site on your Ubuntu, save permalinks twice. This seems to be a WordPress Mantra. Odd.
- Do a backup.
And read all of this : https://github.com/10up/MU-Migration
You should have a Multi-Site WP install at
/var/www/html/, so install mu-migration and separate the sites into zip files:
Here is my command list, for ease of me writing this :
mkdir wp-cli cd wp-cli curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar chmod +x wp-cli.phar sudo cp wp-cli.phar /usr/local/bin/wp wp package install 10up/mu-migration --path=/var/www/html sudo apt-get install php7.0-zip wp site list --path=/var/www/html wp theme status --path=/var/www/html mkdir ~/stuff/mu-migration cd ~/stuff/mu-migration wp mu-migration export all subsite-1.zip --themes --plugins --uploads --blog_id=1 --path=/var/www/html wp mu-migration export all subsite-2.zip --themes --plugins --uploads --blog_id=2 --path=/var/www/html wp mu-migration export all subsite-3.zip --themes --plugins --uploads --blog_id=3 --path=/var/www/html wp mu-migration export all subsite-4.zip --themes --plugins --uploads --blog_id=4 --path=/var/www/html wp mu-migration export all subsite-5.zip --themes --plugins --uploads --blog_id=5 --path=/var/www/html
Create Apache Virtual hosts
/var/www/html/singlesiteN.com (N is 1,2,3,4 and 5 here)
Add singlesite[1-5].com to
127.0.1.1 singlesite1.com 127.0.1.1 singlesite2.com 127.0.1.1 singlesite3.com 127.0.1.1 singlesite4.com 127.0.1.1 singlesite5.com
Go back to https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lamp-on-ubuntu-16-04Install WP into
Import each site :
wp mu-migration import all subsite-1.zip --new_url="singlesite1.com/wp/" --path=/var/www/html/singlesite1.com/wp/ wp mu-migration import all subsite-2.zip --new_url="singlesite2.com/wp/" --path=/var/www/html/singlesite2.com/wp/ wp mu-migration import all subsite-3.zip --new_url="singlesite3.com/wp/" --path=/var/www/html/singlesite3.com/wp/ wp mu-migration import all subsite-4.zip --new_url="singlesite4.com/wp/" --path=/var/www/html/singlesite4.com/wp/ wp mu-migration import all subsite-5.zip --new_url="singlesite5.com/wp/" --path=/var/www/html/singlesite5.com/wp/
If these don’t work due to permission denied issues, go back to https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lamp-on-ubuntu-16-04 and apply the permissions, or try some of your own, or try just running the import again – I never could get a definitive chmod/chown list. YMWV. Yes it will.
So – here you should have single WordPress sites on your Ubuntu machine.
Import to your hosting provider
Back them all up, create new WordPress installations on your hosting provider (Softalicius for example), install UpdraftPlus plugin, do a backup to initialise it and copy the backup files into each site’s
Then attempt a restore. This will hang in all likelihood, so you’ll need to SSH into your host :
cd public_html/singlesite1.com/wp/wp-content unzip updraft/backup...themes.zip unzip updraft/backup...plugins.zip unzip updraft/backup...uploads.zip
That should be it.
The username/passwords will be the same as they were on the original sites, not the ones you used to create the initial WordPress sites.
Final things to do
Install SSL certficates and setup
.htaccess redirections – Google your old sites and see where Google thinks they belong, and redirect accordingly. Then create a Google Search Console account and tell them where all your new sites are, deleting refs to the old ones.
Also change all the passwords you had when creating the sites after the SSL cert install.
There was probably alot more that I had to do, but this post is to give you a flavour on how it could be done, and a reminder for me!
Hope it was slightly useful.