Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Secondary Log Shipping Monitor #5764

Merged
merged 3 commits into from
Jun 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 8 additions & 87 deletions functions/Invoke-DbaDbLogShipping.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -391,189 +391,110 @@ function Invoke-DbaDbLogShipping {
[parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[Alias("SourceServerInstance", "SourceSqlServerSqlServer", "Source")]
[object]$SourceSqlInstance,

[DbaInstanceParameter]$SourceSqlInstance,
[parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[Alias("DestinationServerInstance", "DestinationSqlServer", "Destination")]
[object[]]$DestinationSqlInstance,

[DbaInstanceParameter[]]$DestinationSqlInstance,
[System.Management.Automation.PSCredential]
$SourceSqlCredential,

[System.Management.Automation.PSCredential]
$SourceCredential,

[System.Management.Automation.PSCredential]
$DestinationSqlCredential,

[System.Management.Automation.PSCredential]
$DestinationCredential,

[Parameter(Mandatory, ValueFromPipeline)]
[object[]]$Database,

[parameter(Mandatory)]
[Alias("BackupNetworkPath")]
[string]$SharedPath,
[Alias("BackupLocalPath")]
[string]$LocalPath,

[string]$BackupJob,

[int]$BackupRetention,

[string]$BackupSchedule,

[switch]$BackupScheduleDisabled,

[ValidateSet("Daily", "Weekly", "AgentStart", "IdleComputer")]
[object]$BackupScheduleFrequencyType,

[object[]]$BackupScheduleFrequencyInterval,

[ValidateSet('Time', 'Seconds', 'Minutes', 'Hours')]
[object]$BackupScheduleFrequencySubdayType,

[int]$BackupScheduleFrequencySubdayInterval,

[ValidateSet('Unused', 'First', 'Second', 'Third', 'Fourth', 'Last')]
[object]$BackupScheduleFrequencyRelativeInterval,

[int]$BackupScheduleFrequencyRecurrenceFactor,

[string]$BackupScheduleStartDate,

[string]$BackupScheduleEndDate,

[string]$BackupScheduleStartTime,

[string]$BackupScheduleEndTime,

[int]$BackupThreshold,

[switch]$CompressBackup,

[string]$CopyDestinationFolder,

[string]$CopyJob,

[int]$CopyRetention,

[string]$CopySchedule,

[switch]$CopyScheduleDisabled,

[ValidateSet("Daily", "Weekly", "AgentStart", "IdleComputer")]
[object]$CopyScheduleFrequencyType,

[object[]]$CopyScheduleFrequencyInterval,

[ValidateSet('Time', 'Seconds', 'Minutes', 'Hours')]
[object]$CopyScheduleFrequencySubdayType,

[int]$CopyScheduleFrequencySubdayInterval,

[ValidateSet('Unused', 'First', 'Second', 'Third', 'Fourth', 'Last')]
[object]$CopyScheduleFrequencyRelativeInterval,

[int]$CopyScheduleFrequencyRecurrenceFactor,

[string]$CopyScheduleStartDate,

[string]$CopyScheduleEndDate,

[string]$CopyScheduleStartTime,

[string]$CopyScheduleEndTime,

[switch]$DisconnectUsers,

[string]$FullBackupPath,

[switch]$GenerateFullBackup,

[int]$HistoryRetention,

[switch]$NoRecovery,

[switch]$NoInitialization,

[string]$PrimaryMonitorServer,

[System.Management.Automation.PSCredential]
$PrimaryMonitorCredential,

[ValidateSet(0, "sqlserver", 1, "windows")]
[object]$PrimaryMonitorServerSecurityMode,

[switch]$PrimaryThresholdAlertEnabled,

[string]$RestoreDataFolder,

[string]$RestoreLogFolder,

[int]$RestoreDelay,

[int]$RestoreAlertThreshold,

[string]$RestoreJob,

[int]$RestoreRetention,

[string]$RestoreSchedule,

[switch]$RestoreScheduleDisabled,

[ValidateSet("Daily", "Weekly", "AgentStart", "IdleComputer")]
[object]$RestoreScheduleFrequencyType,

[object[]]$RestoreScheduleFrequencyInterval,

[ValidateSet('Time', 'Seconds', 'Minutes', 'Hours')]
[object]$RestoreScheduleFrequencySubdayType,

[int]$RestoreScheduleFrequencySubdayInterval,

[ValidateSet('Unused', 'First', 'Second', 'Third', 'Fourth', 'Last')]
[object]$RestoreScheduleFrequencyRelativeInterval,

[int]$RestoreScheduleFrequencyRecurrenceFactor,

[string]$RestoreScheduleStartDate,

[string]$RestoreScheduleEndDate,

[string]$RestoreScheduleStartTime,

[string]$RestoreScheduleEndTime,

[int]$RestoreThreshold,

[string]$SecondaryDatabasePrefix,

[string]$SecondaryDatabaseSuffix,

[string]$SecondaryMonitorServer,

[System.Management.Automation.PSCredential]
$SecondaryMonitorCredential,

[ValidateSet(0, "sqlserver", 1, "windows")]
[object]$SecondaryMonitorServerSecurityMode,

[switch]$SecondaryThresholdAlertEnabled,

[switch]$Standby,

[string]$StandbyDirectory,

[switch]$UseExistingFullBackup,

[string]$UseBackupFolder,

[switch]$Force,

[switch]$EnableException
)

Expand All @@ -592,7 +513,7 @@ function Invoke-DbaDbLogShipping {


# Check the instance if it is a named instance
$SourceServerName, $SourceInstanceName = $SourceSqlInstance.Split("\")
$SourceServerName, $SourceInstanceName = $SourceSqlInstance.FullName.Split("\")

if ($null -eq $SourceInstanceName) {
$SourceInstanceName = "MSSQLSERVER"
Expand Down Expand Up @@ -937,7 +858,7 @@ function Invoke-DbaDbLogShipping {
return
}

$DestinationServerName, $DestinationInstanceName = $destInstance.Split("\")
$DestinationServerName, $DestinationInstanceName = $destInstance.FullName.Split("\")

if ($null -eq $DestinationInstanceName) {
$DestinationInstanceName = "MSSQLSERVER"
Expand Down Expand Up @@ -1450,7 +1371,7 @@ function Invoke-DbaDbLogShipping {
}

# Check the primary monitor server
if ($Force -and (-not$PrimaryMonitorServer -or [string]$PrimaryMonitorServer -eq '' -or $null -eq $PrimaryMonitorServer)) {
if ($Force -and (-not $PrimaryMonitorServer -or [string]$PrimaryMonitorServer -eq '' -or $null -eq $PrimaryMonitorServer)) {
Write-Message -Message "Setting monitor server for primary server to $SourceSqlInstance." -Level Verbose
$PrimaryMonitorServer = $SourceSqlInstance
}
Expand Down Expand Up @@ -1714,9 +1635,9 @@ function Invoke-DbaDbLogShipping {
-RestoreThreshold $RestoreThreshold `
-ThresholdAlertEnabled:$SecondaryThresholdAlertEnabled `
-HistoryRetention $HistoryRetention `
-MonitorServer $PrimaryMonitorServer `
-MonitorServerSecurityMode $PrimaryMonitorServerSecurityMode `
-MonitorCredential $PrimaryMonitorCredential
-MonitorServer $SecondaryMonitorServer `
-MonitorServerSecurityMode $SecondaryMonitorServerSecurityMode `
-MonitorCredential $SecondaryMonitorCredential

# Check if the copy job needs to be enabled or disabled
if ($CopyScheduleDisabled) {
Expand Down