How to change the number of post backups in WordPress

WordPress includes a powerful mechanism for saving and storing copies of blog posts, protecting authors from the potential loss of entire content entries. Such losses may be caused by a sudden browser failure or a problem at the operating system level. This WP mechanism also allows older blog entries to be compared with newer versions.

WordPress Quick Tip #1: How to Disable Storage of Post Revisions This feature does, however, have one big disadvantage. By default, it allows a huge number of such backup copies to be generated. This increase in the number of records posted to the wp_posts table can cause the database to become slow and unresponsive and it can significantly increase its size, too (important to those with small hosting plans).

Change the number of backups in the database

Fortunately, this problem is easily solved by switching off the mechanism responsible for creating these copies of blog entries or by restricting it to creating only a few of them.

This requires an easy change – just add the following entry to the wp.config.php file:

define('WP_POST_REVISIONS', 3);

From now on, thanks to this small change WordPress will only create three backup copies of blog entries, minimizing database growth. By modifying the parameter as needed, you get to make use of this wonderful WP feature which can save your content in the event of a software failure, but with the added benefit of controlling the number of backups made and the amount of database space the process consumes.

We recommend adding this entry immediately following a WordPress installation. Adding it later could result in the older blog entry backups only getting cleared out of the database after updates have been made, introducing unnecessarily excessive backups.

Share
This article was first published January 14th, 2013