I have a demo WordPress site that showcases a plugin I created. The plugin lets users interact with content from the front-end and could potentially result in a nightmare of content bloat over time. I'd like to periodically roll back the entire WordPress database to a specific date or backup on a weekly basis. I have looked for plugins that do this - there are auto backup plugins, but I couldn't find any auto restore plugins. I know this is possible because I've seen it done on various other WordPress demo sites in the past.

1 Answer 1


First take a SQL dump of the database in the state you want it. Then you'd write a script that accomplishes the following:

  1. Put the WP install into maintenance mode by creating a file in wp-content with the filename .maintenance and contents "Briefly unavailable for scheduled maintenance. Check back in a minute." (or your preferred text)

  2. Drop all the tables and recreate them from your SQL dump.

  3. Delete /wp-content/.maintenance

Finally hook your script to a cron job in the interval you're looking for. It's best if this script runs completely independently of WP using a system cron job, because there are fewer moving parts and things that could go wrong than if you're trying to do it from within a running WP environment.

  • Are there no plugins that have a feature set similar to this that you know of? Aug 12, 2017 at 13:54
  • Not as far as I know, probably for the reasons outlined in my answer. It would be possible to write one using the same dbDelta() function that WP uses to perform updates, but since we're not interested in preserving any DB contents since your snapshot point it would add needless complexity vs just dropping and recreating the tables from scratch.
    – Chris Cox
    Aug 12, 2017 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.