I maintain a website for my wife called www.delscookingtwist.com. Recently she decided to change her theme. That was big enough a change that I could not simply do it on the live version (which, ahem, so far I had been doing).

I took a copy of her site (copied the entire www/ folder and the entire DB) and moved it to a local server using WAMP. I updated wp-config.php to include a local definition of what the host is.

define( 'WP_SITEURL', 'http://delscookingtwist'); 
define( 'WP_HOME', 'http://delscookingtwist');

I also updated the DB connection info to point to the local DB server where I had imported the dump from the live website

define('DB_NAME', 'xyz');
define('DB_USER', 'xyz');
define('DB_PASSWORD', 'xyz');
define('DB_HOST', 'localhost');

From there on, I made all the changes, tweaks, etc I wanted to do. So far so good. I tested locally.

So now it's time to move the local stuff back to the server. My plan is to

  1. Rename the tables in MySQL with a new prefix
  2. Update Wordpress's config to use the new prefix
  3. Export MySQL dump from my local server and import into the server
  4. Copy the entire contents to another folder e.g. www_v2/
  5. Update the MySQL config in wp-config.php to reflect the server config
  6. Update the WP_SITEURL and WP_HOME to reflect the staging subdomain (see below)
  7. Do a sanity check that everything is working using a subdomain name e.g. test..com
  8. Remove WP_SITEURL and WP_HOME from wp-config so that it falls back to the real value inside the DB
  9. Rename www to www_old
  10. Rename www_v2 to www

Question #1

Does this sound reasonable?

Question #2

Since I started working on a local copy 3 days ago, 3 things (at least) have happened on the live site:

  1. new content
  2. new comments
  3. new statistics

How do I then migrate these changes?


Update - On the topic of changing wordpress DB prefixes

If you do choose to go down the path of changing the prefix, wp-config.php needs to be changed but so do some fields in the DB itself. Here is a great post on what to change.

Here are my SQL commands

SELECT * FROM `wp_new_prefix_options` WHERE `option_name` LIKE '%wp_old_prefix%';
UPDATE `wp_new_prefix_options` set option_name = 'wp_new_prefix_user_roles' where option_name='wp_oldprefix_user_roles' ;
SELECT * from `wp_new_prefix_options` where option_id=92;
SELECT * FROM `wp_new_prefix_usermeta` WHERE `meta_key` LIKE '%wp_old_prefix%';
UPDATE `wp_new_prefix_usermeta` set meta_key = replace(meta_key, 'wp_oldprefix_', 'wp_new_prefix_') WHERE meta_key LIKE '%wp_old_prefix%';
  • 1
    Simply use the Pugin "Duplicator". It's awesome - it makes cloning and then reinstalling very easy. All the stuff which you have written looks a big over the top in my opinion. Just create an image, download the package, update your stuff, create a package on from local copy and Katsching: you are done. Much fewer risk of breaking things in my opinion. Dec 30, 2017 at 3:26
  • I'll have a look. That sounds like a timesaver Dec 30, 2017 at 4:30


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.