Azure Backup fails due to Content Testing Screenshots not clearing

We had a problem with Sitecore 9.0.2 in a PAAS environment. Our Azure App Service backups started failing. This was due to the backup size:Failed Backups

Above 10GB you have to use an Azure Storage Account to store your backup, apparently. However, we wondered why our backups had grown so large – they had been a few GB – and why they seemed to be growing.
I downloaded the last successful backup, and looked at its contents. I found that the /site/wwwroot/temp/screenshots directory appeared to contain about 6GB of images. Here are some of what this directory contains today:

I deleted the /site/wwwroot/temp/screenshots files at the time, and backup was able to run successfully again.

Some research shows that this relates to Content Testing. I noticed that the showconfig.aspx shows a setting:

This looks like it is pointing to the site’s /temp folder, and using ILSpy I can see the following method:

So that’s how the /site/wwwroot/temp/screenshot folder is specified to store screenshots. However, shouldn’t the CleanupAgent be clearing this? Again, I checked showconfig.aspx on the CM server:

The cleanup agent is clearing an entirely different path. Where did that come from? I checked Sitecore.ContentTesting.config and found the following patch:

Okay, so where is $(tempFolder) coming from? Well, next I checked Sitecore.Settings.Azure.config and found the following:

So, it appears that this patch file causes the Sitecore.ContentTesting.config patch file to specify the wrong directory for the CleanupAgent to clean up screenshots from. Therefore, Content Testing screenshots are never removed, and your backups grow until they fail.

I contacted Sitecore about this – they have raised it as a bug #344635. It affects 9.0.2, but doesn’t seem to affect 9.0.1, and I just don’t know about more recent versions.

The solution – configure the CM server’s Sitecore.Tasks.CleanupAgent to clean up the correct folder. We are waiting to deploy this to production:

It just adds an additional target for cleanup, but that’s fine.

Bonus problem: On the CD server, the device detection databases are never deleted. Again this results in an ever-growing backup size. You can use the CleanupAgent to handle that too, as described here by Sitecore Corner: Cleanup Device Detection Databases



Azure Backup fails due to Content Testing Screenshots not clearing

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.