Every now and then we see a requirement from customers who specify that a snapshot of the entire repository for the website be maintained on a deployment or on a daily basis in order to enable a audit of the entire site at a given point in time, or to allow a rollback of the entire site at a given point in time.
The versioning system within Alfresco’s core repository does not natively support snapshots. While it is possible to model this capability within the system through custom coding, the solutions tend to be complex while the demand for the functionality remains low. In any technical solution it is important to keep things as simple as possible. Whenever you run into a narrow requirement that threatens to complicate your systems you need to take a step back and determine:
- Is the requirement is truly necessary?
- Can the requirement can be changed slightly to work better with the existing technology?
- If the requirement is necessary, can you can integrate with a 3rd party that solves the problem directly without complicating the overall solution?
In our example we are left with the third option. Given this, the first question is: are there any existing, robust, affordable solutions for maintaining snapshots of an entire collection of “assets” that already exists and can be cleanly integrated?
The answer is “Yes.” Snapshot capabilities while not very common in web content management systems are extremely common in source code control systems like SVN, Git and others. All of these off the shelf source control systems are extremely robust and are free open source platforms.
Following the idea that we’re going to integrate with an existing source control system to meet the snapshot requirement, the second question is: can our WCM environment represent all content and metadata as files?
Again, with Crafter WEM the answer is yes. All content and metadata are represented as XML files or raw native formats such as images, rich documents, videos etc.
Our third question is obviously: how does the integration work?
Let’s review our business and technical requirements:
- We want a snapshot of content that went LIVE on our site on either a deployment OR daily basis.
- We need to be able to audit the entire site at a given point-in-time if an investigation is required (by law or organizational policy)
- We want a integration with a source control system that does not complicate our overall WCM software and solution.
- Our solution must cover all content and metadata
Now let’s review a potential solution for these requirements.
Getting published content in to the source control system
Because Crafter WEM is a decoupled system where the authoring and delivery system are independent systems separated by an approval process, and a deployment, multi-channel, multi-endpoint deployment is a natural part of the architecture. As you can see in the illustration above, we have a typical deployment to our web infrastructure in the DMZ and we also have a deployment agent inside our corporate firewall, which will put content and metadata in a disk location managed by SVN, Git, or some other source control management system. All metadata and content can be deployed to the source control endpoint.
Delivering content and metadata to the source control system is a simple and robust solution.
Creating a snapshot
To create a snapshot we must check-in (AKA commit) to the source control system.
If we want to create a snapshot on every single deployment we can use a simple callback in our deployment target configuration to perform a check in via a command line operation.
Code Listing 1:
The configuration below demonstrates how to invoke a command line operation from the deployment agent after content has been received.
<beans xsi:schemaLocation="..."> <bean id="MyTarget" init-method="register"> <property name="name"><value>sample</value></property> <property name="manager" ref="TargetManager"/><property name="postProcessors"> <list><ref bean="commitSiteOnDeploy"/></list> </property> <property name="params"> <map> <entry key="root"><value>target/sample</value></entry><entry key="contentFolder"><value>content</value></entry> <entry key="metadataFolder"><value>meta-data</value></entry> </map> </property> </bean> <bean id="commitSiteOnDeploy"> <property name="command" value="svn "/> <property name="arguments"> <map> <entry key="ci" value="PATH TO DEPLOYMENT"/> </map> </property> </bean> </beans>
However, if we want to commit a daily (or any time-based snapshot) we can accomplish this with a simple operating system based scheduled task that performs the check in via a command line operation.
Reviewing a snapshot for audit
Reviewing a snapshot in the event of an audit is as simple as a check out of the particular version from the snapshot repository and launching a Crafter Engine instance on top of the checked out content.
Reverting our WCM environment to a particular version
Reversion of our entire site would require the following steps
- Check out the particular version
- Either create a new WEM project based on the check-out content and re-deploy to your targets
- OR import the checked out site in to your existing WEM project and then deploy to your targets. Take care to analyze your deployment history for deletes as these will need to be managed if you choose to revert over top of your existing project.
Performing Diff Operations
It’s possible to perform a diff operation between versions at any time. Almost all modern source control repositories support version dif functionality.
If you wish to compare the head of your repository with a particular version you can take the following steps:
- Check out the trunk of your snapshot repository
- Copy your preview directory in to your snapshot repository check-out
- Use source control repository to perform diff operation.
Repository snapshots are an important requirement for a small number of organizations. Crafter WEM is able to support these requirements with simple, robust integrations through its deployment architecture and readily available, affordable source control systems.