Prune Old Versions

Over time, the number of revisions for each page will grow. Do you really need versions that were created over two years ago? Given that Confluence stores the entire content for each revision (rather than deltas), this can dramatically increase your database storage requirements.

This job will allow you to automatically prune old page versions according to your requirements, for example:

  • On all spaces, remove versions older than three months, but always keep the latest three versions

  • On spaces where you may have sensitive content, only keep the latest revision

Use the Page Version Age to determine what items will be deleted. The Preset Filters are:

  • Older than 6 months

  • Older than 1 year

  • Older than 2 years

    You also have the option to select a Custom Filter, Older Than. If you select the Older Than value, a screen appears where you choose inputs.

You should specify a user that has permission to edit the pages you want to prune. Specifying an admin account does not necessarily mean all pages will be pruned. CQL respects permissions even against an admin account.

This will irretrievably remove versions according to your rules. They cannot be restored without doing a full space or Confluence restore. Make sure you have tested on your staging instance. At the very least start with a CQL query that selects just test content.

Usage

Start by writing CQL to select the content you are interested in. See the provided examples to select only content from particular spaces etc.

Next specify your parameters for which versions to remove. You must enter at least one of the following, but you can provide both:

  • Minimum number of versions to retain. If no Older than days is provided, it will just delete all versions whilst retaining the latest X

  • If Older than days is provided on its own, all versions older than this number will be removed. If you also provide a minimum number of versions to retain, it will delete the older versions, but only those over the minimum number to retain

For example, to remove versions older than 90 days, but ensure there are always two historical versions, you may use this configuration:

It’s possible to have a general configuration for all spaces, for example, keep all versions made within the last three months and a minimum of three, but more restrictive settings for certain spaces. You would do this simply by setting up two jobs.

This currently only works for blog posts and pages.

The most recent version will never be deleted.

On this page