Created
September 14, 2017 01:06
-
-
Save richardtape/8ced4552f40fda097d6a171a6532a206 to your computer and use it in GitHub Desktop.
wp-cli with sharded databases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Be *very* careful with this. | |
# In your wp-config.php file | |
$db_name = getenv( 'WP_CLI_DB_NAME' ); | |
define( 'DB_NAME', ( !empty( $db_name ) ? $db_name : 'default_global' ) ); # Default often 'wpmu_global' | |
# Then, when calling wp-cli, if the tables you want are in a shard called prefix_3f | |
# And you want to grab the comments table for a site with an ID of 10175 | |
WP_CLI_DB_NAME=prefix_3f; export WP_CLI_DB_NAME; wp db export --tables=wp_10175_comments |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As an addition here, for certain wp-cli commands, such as
wp db tables
you'll also need to include the--url
flag which needs to point at one of the sites that is run from the tables in the shard you're after.