Azure DB Backup

Handian Sudianto 6,621 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 | Other
0 comments No comments
{count} votes

Answer accepted by question author
  1. TP 146.3K 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 146.3K 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' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.