Share via

Script to Remove Old Backups from Azure

vsslasd 556 Reputation points
2022-03-07T16:41:43.627+00:00

We want to delete old backups made from On Premise SQL Server with backups in Azure storage.

Our requirements are as follows:

  • We want to retain the last 30 days of every backup for every database.
    • After 30 days, we want to retain only one backup per month for each database
    • After One Year, we want to keep only one backup per year of each database
  • List item

Backups are performed on a daily basis, so we want to implement a script that will delete those items that don't fall into the above criteria.

Does anyone have a script that can be conformed to these requirements ? Is this best suited as a PowerShell script or a TSQL Script ?

Many thanks,

Developer technologies | Transact-SQL
Developer technologies | Transact-SQL

A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.

0 comments No comments

Answer accepted by question author

Ronen Ariely 15,221 Reputation points
2022-03-07T18:19:12.107+00:00

Hi,

We want to delete old backups made from On Premise SQL Server with backups in Azure storage.

You can use PowerShell script for the task (for example if you want to use Jobs) or GUI tools like Azure Explorer if this a one time work

The on-premises master.dbo.xp_delete_file is not supported for URL

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.