Factory reset shouldn’t be necessary, but when it is, you’ll have your system back by replaying a backup
This should do: