I’m looking for some extra information about an mu site (--url) when attempting to export from a remote server to my local testing environment.

One requirement for migration is the existing blog_id and database prefix. Using those I can do a search/replace on the exported.sql for <wp-prefix>_<blog_id>_ to slot it into the correct db table on import.

Search and Replace

printf "%s" "$(sed "s/$blog_id_old/$blog_id_new/g" <<< "$(gunzip < $input)")" > $output;

Is there a better way to get the blog_id here? And can I get more information like the table prefix without running eval?

Blog ID

blog_id=$(wp eval --url=http://domain.com/site-name/ 'echo get_current_blog_id();');

DB Prefix

prefix=$(wp eval --url=http://domain.com/site-name/ 'global $wpdb; echo $wpdb->prefix;')

Thanks.

0

Leave a Reply

Your email address will not be published. Required fields are marked *