New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add search-replace to db export #709
Comments
I actually coded up a quite fast db-export-with-replacements script last year which we've used internally, and I'll try to open a pull request sometime over the next week that shows how it could enhance WP-CLI. |
@westonruter Can you just share that script in a gist? |
Yeah, sorry, this has been on my todo list for awhile but it got sidelined. I've been thinking about it, and I think that actually the translating export functionality here would be better located in the wp search-replace www.example.com staging.example.com --export=staging.sql If the Thoughts? |
That makes sense. It would be similar to how On Saturday, November 30, 2013, Weston Ruter wrote:
|
Hmm, so a few years later, as far as I can tell only https://deliciousbrains.com/wp-migrate-db-pro/doc/multisite-tools-addon/ has CLI interface available for one direction "subsite -> single site" implementation. Is anybody here still interested in getting WP-CLI modules for all migration combinations going:
I guess https://gist.github.com/westonruter/6277456 does subsite -> subsite right? BackupBuddy probably has the most complete implementation of all these migration options, but they gave up developing it further long ago because of GUI and networking issues complexity. There's some intricacies involved in the process, such as managing the relevant user records on exports/imports. I believe that CLI could get this to the finish line, since it would eliminate a lot of complex timeout problems etc that hinder the GUI. Thoughts? |
If you want to work on subsite -> single-site, etc. database migrations, pull requests are welcome. This issue is for a separate enhancement: exporting a database with replaced values. |
As I tweeted yesterday, it would be great if WP-CLI added support for doing search-replace during the db export process, so that replacements would not have to be done in-place. In order to migrate a database from staging to production, for example, the process with WP-CLI is currently a bit convoluted. I gisted a bash script which incorporates the necessary steps with WP-CLI (here to also export only the specific tables for a site in a multisite network), but in general they would be:
wp db export backup-snapshot.sql
(snapshot restore point)wp db search-replace staging.example.com www.example.com
wp db export production.sql
wp db import backup-snapshot.sql
(rollback to restore point)So then as I later tweeted, what if the
wp db export
subcommand accepted--search
and--replace
arguments to do the translations during the export process? For example, the above 4 commands could all be done with just one:This then would go along very nicely with the proposed
wp db list-tables
to export a single site from a multisite network for promotion from staging to production. See #708.As @scribu points out, this means we can't use
mysqldump
which is really fast. True, but we would avoid having to accompany eachwp search-replace
with two calls towp db export
and once towp db import
.The text was updated successfully, but these errors were encountered: