< Back
Test-DbaDbRecoveryModel
Post
NAME Test-DbaDbRecoveryModel
SYNOPSIS
Find if database is really a specific recovery model or not.
SYNTAX
Test-DbaDbRecoveryModel [-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]> [[-Database]
<System.Object[]>] [[-ExcludeDatabase] <System.Object[]>] [[-SqlCredential] <Pscredential>] [[-RecoveryModel]
<System.Object>] [-EnableException <Switch>] [<CommonParameters>]
DESCRIPTION
When you switch a database into FULL recovery model, it will behave like a SIMPLE recovery model until a full
backup is taken in order to begin a log backup chain.
However, you may also desire to validate if a database is SIMPLE or BULK LOGGED on an instance.
Inspired by Paul Randal's post
(http://www.sqlskills.com/blogs/paul/new ... very-mode/)
PARAMETERS
-Database [<System.Object[]>]
Specifies the database(s) to process. Options for this list are auto-populated from the server. If
unspecified, all databases will be processed.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-EnableException [<Switch>]
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables
advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own
try/catch.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-ExcludeDatabase [<System.Object[]>]
Specifies the database(s) to exclude from processing. Options for this list are auto-populated from the server.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-RecoveryModel [<System.Object>]
Specifies the type of recovery model you wish to test. By default it will test for FULL Recovery Model.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlCredential [<Pscredential>]
Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory -
Integrated are all supported.
For MFA support, please use Connect-DbaInstance.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlInstance [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]
The target SQL Server instance or instances.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
System.Collections.ArrayList
NOTES
Tags: DisasterRecovery, Backup
Author: Claudio Silva (@ClaudioESSilva)
Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: GNU GPL v3 https://opensource.org/licenses/GPL-3.0
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Test-DbaDbRecoveryModel -SqlInstance sql2005
Shows all databases where the configured recovery model is FULL and indicates whether or not they are really in
FULL recovery model.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Test-DbaDbRecoveryModel -SqlInstance . | Where-Object {$_.ActualRecoveryModel -ne "FULL"}
Only shows the databases that are functionally in 'simple' mode.
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>Test-DbaDbRecoveryModel -SqlInstance sql2008 -RecoveryModel Bulk_Logged | Sort-Object Server -Descending
Shows all databases where the configured recovery model is BULK_LOGGED and sort them by server name descending
-------------------------- EXAMPLE 4 --------------------------
PS C:\\>Test-DbaDbRecoveryModel -SqlInstance localhost | Select-Object -Property *
Shows all of the properties for the databases that have Full Recovery Model
RELATED LINKS
https://dbatools.io/Test-DbaDbRecoveryModel
SYNOPSIS
Find if database is really a specific recovery model or not.
SYNTAX
Test-DbaDbRecoveryModel [-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]> [[-Database]
<System.Object[]>] [[-ExcludeDatabase] <System.Object[]>] [[-SqlCredential] <Pscredential>] [[-RecoveryModel]
<System.Object>] [-EnableException <Switch>] [<CommonParameters>]
DESCRIPTION
When you switch a database into FULL recovery model, it will behave like a SIMPLE recovery model until a full
backup is taken in order to begin a log backup chain.
However, you may also desire to validate if a database is SIMPLE or BULK LOGGED on an instance.
Inspired by Paul Randal's post
(http://www.sqlskills.com/blogs/paul/new ... very-mode/)
PARAMETERS
-Database [<System.Object[]>]
Specifies the database(s) to process. Options for this list are auto-populated from the server. If
unspecified, all databases will be processed.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-EnableException [<Switch>]
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables
advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own
try/catch.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-ExcludeDatabase [<System.Object[]>]
Specifies the database(s) to exclude from processing. Options for this list are auto-populated from the server.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-RecoveryModel [<System.Object>]
Specifies the type of recovery model you wish to test. By default it will test for FULL Recovery Model.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlCredential [<Pscredential>]
Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory -
Integrated are all supported.
For MFA support, please use Connect-DbaInstance.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlInstance [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]
The target SQL Server instance or instances.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
System.Collections.ArrayList
NOTES
Tags: DisasterRecovery, Backup
Author: Claudio Silva (@ClaudioESSilva)
Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: GNU GPL v3 https://opensource.org/licenses/GPL-3.0
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Test-DbaDbRecoveryModel -SqlInstance sql2005
Shows all databases where the configured recovery model is FULL and indicates whether or not they are really in
FULL recovery model.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Test-DbaDbRecoveryModel -SqlInstance . | Where-Object {$_.ActualRecoveryModel -ne "FULL"}
Only shows the databases that are functionally in 'simple' mode.
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>Test-DbaDbRecoveryModel -SqlInstance sql2008 -RecoveryModel Bulk_Logged | Sort-Object Server -Descending
Shows all databases where the configured recovery model is BULK_LOGGED and sort them by server name descending
-------------------------- EXAMPLE 4 --------------------------
PS C:\\>Test-DbaDbRecoveryModel -SqlInstance localhost | Select-Object -Property *
Shows all of the properties for the databases that have Full Recovery Model
RELATED LINKS
https://dbatools.io/Test-DbaDbRecoveryModel