Migrate Multisite WP

 

Type of WP Migration:

  1. Full WP migration
    1. WP Singlesite to WP Singlesite
    2. WP Multisite to WP Multisite
    3. WP Singlesite to WP Singlesite different domain name
    4. WP Multisite to WP Multisite different Net-Site domain name
  2. One Site migration
    1. WP Singlesite to WP Multisite Sub-site
    2. WP Singlesite to WP Multisite Net-site
    3. WP Multisite Net-site to WP Singlesite
    4. WP Multisite Sub-site to WP Singlesite
    5. WP Multisite Net-site to WP Multisite Net-site
    6. WP Multisite Net-site to WP Multisite Sub-site
    7. WP Multisite Sub-site to WP Multisite Net-site
    8. WP Multisite Sub-site to WP Multisite Sub-site

The best strategy for a one site migration is: grab a site into a WP site backup set, that can be uploaded to WP Singlesite, WP Multisite Net-site or WP Multisite Sub-site.

Standard Manual Site Migration

Migrating single site or single multi-site (not the root multi-site/main network site), to or from single-site or multi-site WP Host, can be done manually:

  1. Create a new site on Target WP Host, resolved by its Target Domain Name.
    For migrating to new domain with secure certificate (HTTPS), make sure the SSL already installed and https://targetdomain.com already resolved to the new site.
    For migrating same domain, keep the old http or https://samedomain.com, and use a temporary name on Target WP Host: http or https://temp.samedomain.com.
  2. Install / update Target WP Host to match Source WP Host
    Admin email: Both Host must have same admin email and the admin user registered.
    Plugins: Both Host must have same plugins installed.
    Themes: Both Host must have same active theme installed. Remove unused Themes.
    Site Settings: Both Host must have same site setting.
    If both host not exactly the same it will only add some risk. Most of the time the migration will succeed.Multisite must have MU Domain Mapping pluggins, and note the Site ID number from Network Admin – Settings – Domain. The number is marking table prefix for each site on multi-site WP.Install Maintenance plugins.
  3. Minimize
    Plugins: disable plugins that is not critical
    Themes: disable themes that is not critical
  4. Create backup of Target WP Host
  5. Copy Source WP Host site files
    wp-plugins (if customization made here)
    wp-themes (if customization made here)
    other files for the site that is not part of core WP.For single-site:
    Compress wp-content/uploads/ as uploads.tar.gz
    sudo tar -C /var/www/wordpress/wp-content/uploads -zcvf uploads.tar.gz .
    For multi-site:
    Check the site ID number M from Source WP Host – Settings – Domain.
    Compress wp-content/uploads/sites/M as uploads.tar.gz
    sudo tar -C /var/www/wordpress/wp-content/uploads/sites/M -zcvf uploads.tar.gz .Transfer the file to Target WP Host
    scp uploads.tar.gz targetusername@targetIP:folder
    Example:
    scp uploads.tar.gz michelle@172.17.17.17:.
    The file will be transferred to michelle home directory.
    scp -v -P 22222 uploads.tar.gz jonh@172.17.17.17:.
    -P portnumber: If SSH port already move from 22 to portnumber
    -v: verbose, to check for error

    Remove the upload.tar.gz file afterward (reduce security risk):
    rm upload.tar.gz

  6. Copy Source WP Host database to a temporary
    Export Source WP Host Database: wordpress
    Create new temporary database on Target WP Host: tempdb
    Import Source WP Host Database to tempdb on Target WP HostTo migrate single site from multi-site, only Export the site tables to tempdb on Target WP Host. Check the site ID number N from Source WP Host – Settings – Domain, and the tables are using that number in its prefix: wp_N_tablename.
    Or if migrating using full backup database, delete other site table after importing to the tempdb on Target WP Host.
  7. Replace domain name on tables contents
    Download dbmaster tool.
    Unzip dbmaster tool on Target WP Host webroot.
    Using dbmaster tool, on tempdb, search and replace from HTTP or HTTPS://sourcedomain.com to HTTP or HTTPS://targetdomain.com.
    Delete dbmaster tool from webroot (reduce security risk).
  8. Make sure the admin email is correct on wp_options
  9. Delete site tables on Target WP Host database
  10. Import site tables from tempdb to Target WP Host database
  11. Restore the Source WP Host files on Target WP Hostsudo tar -xvzf uploads.tar.gz -C /var/www/wordpress/wp-content/uploads
    Or for site ID N on multi-site:
    sudo tar -xvzf uploads.tar.gz -C /var/www/wordpress/wp-content/uploads/sites/NRepair /uploads file privileges:
    sudo chmod -R 755 /var/www/wordpress/wp-content/uploads
    sudo chown -R www-data:www-data /var/www/wordpress/wp-content/uploads

    Remove the uploads.tar.gz (reduce security risk):
    rm uploads.tar.gz

  12. Test the migrated new site
    Turn on Maintenance on the new site.
  13. Delete the tempdb
  14. Finalize migration
    Turn on Maintenance on Source Host, turn off Maintenance on Target Host.
  15. Check and test the new site

HTTPS Sub-Site Same Domain Host Migration

The aim of these procedure is to make sure that the new site will have all contents of the old site, while minimizing down time of the domain.

  1. Create New Site on the New Host https://domain.com.
  2. If needed, set the Original Site on the Old Host to Maintenance Mode On. 
  3. Direct http://domain.com DNS A Record from Old Host IP to the New Host IP. Offline time starts. The domain.com will then resolved to New Host non SSL web server. 
  4. Copy latest sub-site database tables, and change the table prefix to New Host using local network IP.
  5. Copy latest sub-site /uploads folder to New Host using local network IP.
  6. Extend domain.com on New Host SSL, and register as SSL server on the conf file. 
  7. Check Nginx configuration and reload Nginx. The https://domain.com will be served from the New Host. Offline time ends here.
  8. Turn Maintenance Mode Off on the New Host if its On.
  9. Test the https://domain.com on New Host.

Minimizing downtime:

  1. Use script to:
    1. Copy the latest sub-site database tables
    2. Change the table prefix
    3. Export and compress the SQL file
    4. Send the file from Old Host to New Host
    5. Import SQL on New Host database
    6. Compress /uploads/M folder, send compressed /uploads folder to New Host, and move to the /uploads/N on New Host
  2. Use DNS server that have fast A Record change response time.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s