commands

^

Remove-DbaDbLogShipping

Author Sander Stad (@sqlstad), sqlstad.nl
Availability Windows only

 

Synopsis

Remove-DbaDbLogShipping will remove one or more databases from log shipping

Description

The command Remove-DbaDbLogShipping will remove one or more databases from log shipping

After running the command it will remove all the jobs, configurations set up for log shipping

By default the secondary database will NOT be removed. Use -RemoveSecondaryDatabase to make the command the secondary database

Syntax

Remove-DbaDbLogShipping
    [-PrimarySqlInstance] <DbaInstanceParameter>
    [[-SecondarySqlInstance] <DbaInstanceParameter>]
    [[-PrimarySqlCredential] <PSCredential>]
    [[-SecondarySqlCredential] <PSCredential>]
    [-Database] <Object[]>
    [-RemoveSecondaryDatabase]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Remove-DbaDbLogShipping -PrimarySqlInstance sql1 -SecondarySqlInstance sql2 -Database DB1

Remove the log shipping for database DB1

Example: 2
PS C:\> Remove-DbaDbLogShipping -PrimarySqlInstance sql1 -Database DB1

Remove the log shipping for database DB1 and let the command figure out the secondary instance

Example: 3
PS C:\> Remove-DbaDbLogShipping -PrimarySqlInstance localhost -SecondarySqlInstance sql2 -Database DB1, DB2

Remove the log shipping for multiple database

Example: 4
PS C:\> Remove-DbaDbLogShipping -PrimarySqlInstance localhost -SecondarySqlInstance localhost -Database DB2 -RemoveSecondaryDatabase

Remove the log shipping for database DB2 and remove the database from the secondary instance

Required Parameters

-PrimarySqlInstance

Primary SQL Server instance which contains the primary database(s). You must have sysadmin access and server version must be SQL Server version 2000 or greater.

Alias
Required True
Pipeline false
Default Value
-Database

Database to remove from log shipping. This is the name of the database located on the primary instance

Alias
Required True
Pipeline true (ByValue)
Default Value

Optional Parameters

-SecondarySqlInstance

Secondary SQL Server instance which contains the secondary database(s) You must have sysadmin access and server version must be SQL Server version 2000 or greater.

Alias
Required False
Pipeline false
Default Value
-PrimarySqlCredential

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.

Alias
Required False
Pipeline false
Default Value
-SecondarySqlCredential

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.

Alias
Required False
Pipeline false
Default Value
-RemoveSecondaryDatabase

By default the command will not remove the database from the secondary instance. Use this parameter to make the command remove that database

Alias
Required False
Pipeline false
Default Value False
-EnableException

Use this switch to disable any kind of verbose messages

Alias
Required False
Pipeline false
Default Value False
-WhatIf

Shows what would happen if the command were to run. No actions are actually performed.

Alias wi
Required False
Pipeline false
Default Value
-Confirm

Prompts you for confirmation before executing any changing operations within the command.

Alias cf
Required False
Pipeline false
Default Value

 

Want to see the source code for this command? Check out Remove-DbaDbLogShipping on GitHub.
Want to see the Bill Of Health for this command? Check out Remove-DbaDbLogShipping.