Have you ever wondered how to keep Alfresco running while backing it up? As you may have found it, Alfresco database and data filesystem have to be saved in a coherent state. For this, Alfresco should be turned off, or in a read-only mode. A read-only mode is also useful for some maintainance operations.

On Alfresco 1.4, I could put it in a read-only mode by changing the transactions.properties file and restarting Alfresco. This doesn't work on Alfresco 2.1 as Alfresco tries to write some informations in the system repositories during the bootstrap. Thus the only way to set it in a read-only mode is to do it without stopping it, by interacting with the TransactionService. This post is about to explain how to create a webscript to toggle Alfresco in read-only or read-write mode.