Update: The full updated plugin code with additional description can be found here:
http://justinsilver.com/technology/wordpress/wordpress-plugins/wordpress-plugin-wp-server-migration/
I was able to come up with a solution using @ user916011. I needed to copy the
wp_options tables into my development environment since they contain the necessary configurations. To solve the problem of the inability to set the values of WP_SITEURL and WP_HOME in MultiSite, I wrote a special filter to replace the
_config_wp_siteurl() and
_config_wp_home() functions that are available for non-multisite installations, which are included in the plugin, which is available on a network-wide basis and configured in
wp-config.php . Then I can copy all the database tables except
wp_site and
wp_blogs to the local database.
I highly recommend the WordPress 3.0 URL Token Replacement Methods written by Chris Murphy to handle the URLs in your content.
This example assumes that the subdomain uses a multi-node installation with the example.com domain and two subdomains, www.example.com and second.example.com . The local development URLs will be www.example.local and second.example.local respectively.
Database changes :
Update domain value in wp_site :
UPDATE wp_site SET domain = 'example.local' WHERE domain = 'example.com';
Update domain values (s) in wp_blogs :
UPDATE wp_blogs SET domain = 'www.example.local' WHERE domain = 'www.example.com'; UPDATE wp_blogs SET domain = 'second.example.local' WHERE domain = 'second.example.com';
Plugin code : The following plugin must be installed throughout the network.
<?php function _ms_config_wp_siteurl( $url = '' ) { if (is_multisite()): global $blog_id, $current_site; $cur_blog_id = defined('BLOG_ID_CURRENT_SITE')? BLOG_ID_CURRENT_SITE : 1; $key = ($blog_id!=$cur_blog_id)? $blog_id.'_' : ''; $constant = 'WP_'.$key.'SITEURL'; if ( defined( $constant ) ) return untrailingslashit( constant($constant) ); endif; return $url; } add_filter( 'option_siteurl', '_ms_config_wp_siteurl' ); function _ms_config_wp_home( $url = '' ) { if (is_multisite()): global $blog_id; $cur_blog_id = defined('BLOG_ID_CURRENT_SITE')? BLOG_ID_CURRENT_SITE : 1; $key = ($blog_id!=$cur_blog_id)? $blog_id.'_' : ''; $constant = 'WP_'.$key.'HOME'; if ( defined( $constant ) ) return untrailingslashit( constant($constant) ); endif; return $url; } add_filter( 'option_home', '_ms_config_wp_home' ); ?>
Configure wp-config.php :
Add new constants to wp-config.php . The main site should use standard WP_HOME and WP_SITEURL , and tertiary URLs should use WP_{$blog_id}_HOME and WP_{$blog_id}_SITEURL
define('WP_HOME', 'http://www.example.local'); define('WP_SITEURL', 'http://www.example.local'); define('WP_2_HOME', 'http://secondary.example.local'); define('WP_2_SITEURL', 'http://secondary.example.local');