Remove obsolete plugins artifacts from database tables

I’m dealing with some long-running WordPress blog. It was moved to different servers several times, and the migration process haven’t followed «the WordPress way» from time to time — just a database backup and restore with clean WordPress install.

So, now I see a lot of artifacts from obsolete plugins in database tables (options, cronjobs, etc).

I’m looking for a way to remove those traces.

To remove obsolete options from wp_options I’m going to do the following:

  1. Backup, backup, verify that restore from backups works, backup once again.
  2. Extract all the option names from WordPress sources and currently installed plugins with some grep/sed/awk.
  3. Run the following MySQL query: DELETE FROM wp_options WHERE option_name NOT IN (%OPTION_NAMES_FROM_WORDPRESS_AND_PLUGINS%)

Will this work? How to deal with cron jobs? May there be any more artifacts to look for?

0

Leave a Comment