Clean up Old Backup Files Failed with Encrypted Backups

The MaintenanceSolution is a great piece of T-SQL script from Ola Hallengren.
When I turn on the encryption for new backups, all backup files created are ignoring the command from xp_delete_file.
The reason is that this stored procedure is check file header to work with backup or log file it recognizes. It seems the encrypted version is not picked up so no cleanup happens and all encrypted backup files stay untouched.
Here is a sample code I copied from my system:

Exec [master].dbo.xp_delete_file 0, N’C:\Backup\myServerName\myDB\FULL_COPY_ONLY’, ‘bak’
–, ‘2016-03-03T16:03:21’

One alternative solution:
To create an SSIS package with a powerhsell script to clean these old encrypted backup files and run as a scheduled job.


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 )

Google+ photo

You are commenting using your Google+ 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