Checking if your SIMPLE databases need a log backup

Posted by Fatherjack on Simple Talk See other posts from Simple Talk or by Fatherjack
Published on Tue, 10 Jun 2014 10:43:09 +0000 Indexed on 2014/06/10 15:37 UTC
Read the original article Hit count: 415

Filed under:

Hopefully you have read the blog by William Durkin explaining why your SIMPLE databases need a log backup in some cases. There is a SQL Server bug that means in some cases databases are marked as being in SIMPLE RECOVERY but have a log wait type that shows they are not properly configured. Please read his blog for the full explanation and a great description of how to reproduce the issue.

As part of our (William happens to be my Boss) work to recover our affected databases I wrote this small PowerShell script to quickly check our servers for databases that needed the attention that William details.

 cls

$Servers = “Server01″,”Server02″,”etc”,”etc”

foreach($Server in $Servers){

write-host “************” $server “****************”

    $server = New-Object Microsoft.sqlserver.management.smo.server $Server

    foreach($db in $Server.databases){

        $db | where {$_.RecoveryModel -eq “Simple” -and $_.logreusewaitstatus -ne “nothing”} | select name, LogReuseWaitStatus

    }

}

If you get any results from this query then you should consult Williams blog for the details on what action you should take. This script does give out false positives if in some circumstances depending on how busy your databases are.

Hopefully this will let you check your servers quickly and if you find any problems you can reference Williams blog to understand what you need to do.

© Simple Talk or respective owner

Related posts about Uncategorized