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
- Rename the tables in MySQL with a new prefix
- Update Wordpress's config to use the new prefix
- Export MySQL dump from my local server and import into the server
- Copy the entire contents to another folder e.g. www_v2/
- Update the MySQL config in wp-config.php to reflect the server config
- Update the WP_SITEURL and WP_HOME to reflect the staging subdomain (see below)
- Do a sanity check that everything is working using a subdomain name e.g. test..com
- Remove WP_SITEURL and WP_HOME from wp-config so that it falls back to the real value inside the DB
- Rename www to www_old
- Rename www_v2 to www
Does this sound reasonable?
Since I started working on a local copy 3 days ago, 3 things (at least) have happened on the live site:
- new content
- new comments
- 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%';