In my previous post we get idea about content lifecycle within Alfresco. Now when alfresco instance used for long time means for many years there are various contents uploaded and deleted and as we have seen in the content lifecycle post that orphan contents are always there in the alfresco filesystem so ultimately it will increase the size of that file system become mammoth and will be difficult to handle.
Best way to handle deleted contents is by configuring contentstoreCleaner. It can be done by following steps.
Orphaned content can be deleted or purged from the content store while the system is running. Identifying and either sequestering or deleting the orphaned content is the job of the contentStoreCleaner.
contentStoreCleanerTrigger fires the contentStoreCleaner bean.
<bean id="contentStoreCleaner" class="org.alfresco.repo.content.cleanup.ContentStoreCleaner" > <property name="protectDays" > <value>20</value> </property> <property name="stores" > <list> <ref bean="fileContentStore" /> </list> </property> <property name="listeners" > <list> <ref bean="deletedContentBackupListener" /> </list> </property> </bean>
This property to state the minimum time that content binaries should be kept in the contentStore. In the above example, if a file is created and immediately deleted, it will not be cleaned from the contentStore for at least 20 days. It should never be 0.
protectDays> number of days between successive backup runs(In case of system backup strategy is just to make regular copies)
This is a list of ContentStore beans to scour for orphaned content.
When orphaned content is located, these listeners are notified. In this example, the deletedContentBackupListener copies the orphaned content to a separate deletedContentStore.
Note that this configuration will not actually remove the files from the file system but rather moves them to the designated deletedContentStore, usually contentstore.deleted. After moving an orphaned content file out of the active content-store, the relevant line in the alf_content_url table deleted from the DB. The files can be removed from the deletedContentStore via script or cron job once an appropriate backup has been performed.