Azure DB Backup

Handian Sudianto 6,071 Reputation points
2023-05-30T04:39:18.9266667+00:00

Hello,

Can we make an script / automation to detect if there any SQL Database with no available LTR backups?

User's image

Azure SQL Database
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,492 questions
0 comments No comments
{count} votes

Accepted answer
  1. TP 123.5K Reputation points Volunteer Moderator
    2023-05-30T09:30:30.4133333+00:00

    Hi,

    Below will return list of databases on Azure SQL without LTR backup, excluding master:

    $databases = Get-AzSqlDatabase -ResourceGroupName yourResourceGroup -ServerName yourAzureSqlServer|where DatabaseName -ne "master" 
    $databases|ForEach-Object -Process {if ((Get-AzSqlDatabaseLongTermRetentionBackup -Location $_.Location -ServerName $_.ServerName) -eq $null) {$_.DatabaseName} }|Out-File databases.txt -noClobber
    
    

    -TP


1 additional answer

Sort by: Most helpful
  1. TP 123.5K Reputation points Volunteer Moderator
    2023-06-12T06:12:18.83+00:00

    So that I can try to recreate this, can you tell me what might be different about this database, besides the name? I see the earliest PITR is more recent than the others in the list, and you mentioned LTR isn't enabled for it, anything else?


Your answer

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