ideas
ideas copied to clipboard
Migrate command
We often have to migrate web sites from local dev machines or staging machines to production. The standard process is something like:
- Dump the database to a file
- Zip up the project (including the db dump)
- Copy the compressed archive to the new server
- Unzip the archive to the web root
- Import the database
- Search and replace URLs for the new domain
- Modify wp-config.php for the new database
- Pull our hair out wondering why some theme and plugin options didn't show up in the new site and end up either updating them manually or using the often fallible theme option import/export feature.
It would be great if wp-cli could assist in this process. I think most of the tools are already there (search-replace, generate a default wp-config file, etc.) but the migrate
command would bundle the entire process and should probably be complimented with a deploy
command as well.
I've tried to do this in bash and it mostly works but the restore script has issues. Also, I'm not using wp-cli in my script but I've already started writing code to use it as it does a much, much better job searching and replacing.
And regarding searching and replacing… I've noticed that revslider, and probably other plugins, stores URLs as http://domain.com/somedir/anotherdir etc. Neither my script nor wp-cli succeeds at matching this escaped URL but perhaps it's just out of scope and I'll have to learn to live with it.
I sure hope this gets included in a future version of wp-cli.
Thanks!
Ted Stresen-Reuter
Related #14 and #5
Pull our hair out wondering why some theme and plugin options didn't show up in the new site and end up either updating them manually or using the often fallible theme option import/export feature.
I started on https://github.com/runcommand/manifest as a way to create a simple document representing the state of WordPress, such that you could easily compare before and after to verify the migration proceeded correctly.
And regarding searching and replacing… I've noticed that revslider, and probably other plugins, stores URLs as http://domain.com/somedir/anotherdir etc. Neither my script nor wp-cli succeeds at matching this escaped URL but perhaps it's just out of scope and I'll have to learn to live with it.
Can you open a new WP-CLI issue and provide test steps to reproduce?
a way to create a simple document representing the state of WordPress
Will look into it, see if it can help. Thanks!
Can you open a new WP-CLI issue and provide test steps to reproduce?
You bet, where?
Hi @tedmasterweb,
You bet, where?
You can post an issue here: https://github.com/wp-cli/wp-cli/issues
Thanks @trepmal. All done: https://github.com/wp-cli/wp-cli/issues/3753
And regarding searching and replacing… I've noticed that revslider, and probably other plugins, stores URLs as http://domain.com/somedir/anotherdir etc. Neither my script nor wp-cli succeeds at matching this escaped URL but perhaps it's just out of scope and I'll have to learn to live with it.
WP-CLI's search-replace cannot replace url's stored by revslider hence I have created a custom command for this, I have been using it since a long time now and it does get the job done.