Open 37Rb opened 1 month ago
Thanks for the suggestion, @37Rb !
I think it's unlikely that we'll add something like this to WP-CLI itself in the near future. Some complexities that come to mind:
You're welcome to create your own WP-CLI package around this, though. If you find a robust solution for this, we could consider adopting it as a community package.
You're right that just copying files wouldn't always work when a plugin update makes database changes. I've found most plugin updates don't make database changes. The ones that do usually add something to the database so rolling back just means the old version ignores what was added. But there would definitely be cases where it would cause a problem.
I think the popular WP Rollback plugin has this same issue and people use it. Doing wp plugin update --version=<version>
to an older version would also have this issue but wp-cli allows it.
I'm happy to continue using the bash scripts I already have if it's unlikely to be added to wp-cli. I just thought others might want a plugin restore like I did.
Updating plugins on a live site is scary. Yes, we should test updates on a staging site first, and we do, but problems can still occur. Wp-cli is great for updating plugins but it would be even better if there were a built-in backup and restore for plugin updates. The currently available options I'm aware of for backup & restore are:
wp plugin update --version=<version>
(doesn't work for all plugins)I would like:
wp plugin update
to locally back up the plugin version being replaced before doing the updatewp plugin restore
command that rolls back to a backed up plugin versionThe advantages of this would be:
I've written a couple short bash scripts to do this after a recent situation where a plugin update appeared to work fine in staging but created a huge problem in production that wasn't visible until later. I can use scripts like this but it would be great if it were built into wp-cli. I can attempt to do it PHP and contribute the code if you think it's a good idea.
wp plugin update (bash example)
wp plugin restore (bash example)