olahallengren / sql-server-maintenance-solution

SQL Server Maintenance Solution
https://ola.hallengren.com
MIT License
2.91k stars 756 forks source link

Cleanup is not supported on Azure Blob Storage #820

Closed mbento62 closed 2 weeks ago

mbento62 commented 2 months ago

Hi. I use the backup ola.hallegren process to execute backup process (work fine), but when I configured to delete files, I receive this message: (I'm working with Azure storage account as backup files repository): The value for the parameter https://github.com/Cleanuptime is not supported. Cleanup is not supported on Azure Blob Storage. [SQLSTATE 42000] (Error 50000) [SQLSTATE 01000] (Message 50000) The documentation is available at https://ola.hallengren.com/sql-server-backup.html. [SQLSTATE 42000] (Error 50000) [SQLSTATE 01000] (Message 50000) Date and time: 2024-09-10 09:00:00 [SQLSTATE 01000] (Message 50000) [SQLSTATE 01000] (Message 50000). The step failed. But, I don't found explanation how I can delete files with [dbo].[DatabaseBackup] Thanks !!!

griffitmatt commented 2 months ago

The link below has the answer to your question

https://ola.hallengren.com/frequently-asked-questions.html

"How can I delete old backup files from Azure Blob Storage?

I have not been able to find a way to delete backup files in Azure Blob Storage from a T-SQL stored procedure. Because of that you cannot use the @CleanupTime parameter when you do backup to URL.

You will have to use a PowerShell script to delete old backup files in Azure Blob Storage. Here is one that you can use."

david-garcia-garcia commented 3 weeks ago

I built a Powershell script to deal with cleanup support, trying to emulate the backup solution behavior. You can find the implementation here:

https://github.com/david-garcia-garcia/windowscontainers/blob/master/sqlserver2022k8s/setup/backups/assets/Program%20Files/WindowsPowershell/Modules/Sbs/Functions/SbsMssqlCleanupBackups.ps1

This is part of a Windows Container based MSSQL container image.