-
Notifications
You must be signed in to change notification settings - Fork 101
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 scheduled user-role backup and management CLI #1982
Conversation
Tested pretty extensively, all went well. |
…warning about removing old backups
… add confirmation
@@ -10,9 +10,13 @@ | |||
|
|||
use Automattic\VIP\Utils\Alerts; | |||
|
|||
define( 'USER_ROLE_BACKUP_LENGTH', 3 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we prefix this with VIP_
? And also, just curious if there would be any harm in upping this to say 5 - since we aren't autoloading it shouldn't matter, and will better help protect against maybe a weekend problem that went unnoticed for 3 days?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@WPprodigy this file is namespaced so that'll also cover the constant.
This reverts commit 3d3250b. I realized this only affects staging, where there is much less impact, so splitting it up here is an over optimization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested it all out and it works great!
r1391-stacks |
Description
Adds 1) a cron job to regularly backup user roles to a secondary option and 2) a CLI to manage listing/viewing/restoring those backups to the primary.
Why? In some cases of option corruption, user roles are lost and restoration is complicated and/or slow. This intends to make it quick and easy.
Note: this deals with the
wp_user_roles
option, not the assignments to users.Changelog Description
Added User Role Backups
This change adds an automated daily backup of the user roles option that can be used to recover roles if they are corrupted. It also adds some CLI commands to aid in managing these backups.
Checklist
Please make sure the items below have been covered before requesting a review:
Steps to Test
Begin by backing up current roles, then alter roles and backup again:
A couple options will now be listed in
wp vip role-backup list
wp vip role-backup view [<time_key>]
wp vip role-backup restore [<time_key>]
wp role list