Removing Sitecore archive entries older than a specified date
July 26, 2016
The recycle bin and archive within Sitecore are useful features
for content editors, the problem is that unless somebody proactively
keeps removing items from them, then they will keep growing in size.
For example, I once saw the archive tables reach 3GB.
Firstly, the following Sitecore setting must be set to true
to ensure items are put in the recycle bin rather than being
permanently deleted when a content editor deletes an item:
To remove the need for somebody to keep going into the Sitecore
client and cleaning up the recycle bin (or archive) manually, the following
Sitecore Job will keep checking the entries on a set interval and
remove any items older than the configured DaysToKeep setting.
For example, you could configure the job to keep all items deleted in the past
90 days but remove older items as they are unlikely to be needed:
To add the job to your application, create a new include file with
the following configuration:
You can configure the DaysToKeep, ArchiveName
and DatabaseName parameters to customise the job to run
how you need it to be run. To run against multiple databases or
multiple archives, simply specify multiple agent configuration
nodes for each setup required.
When the job runs, it will log something similar to the following
if INFO logging is enabled: