Version: MScubed 2K8 R2
Hi. I'm a total newb and whilst configuring Transaction Log Shipping could not invoke that with the final [ OK ] due to an obscured network issue (the live server could see the DR server but not the other way around - netstat -a showed ephemeral ports exhaisted, resolved with a reboot).
So I used the Script Configuration option and later ran the script to reproduce the problem.
The script has two halves (see below), the top one to be run on the live server and the bottom one, not indicated in the header, to be run on the DR server.
I therefore have erroneous jobs on the live server.
A more experienced colleague says it's not as simple as deleting them.
The Job Activity Monitor shows two jobs that shoudn't be there:
LSCopy_INVSQLLIVE_BPM . enabled . Executing . Succeeded
LSRestore_INVSQLLIVE_BPM . enabled . Idle . Failed
as the result of running this script:
-- Execute the following statements at the Primary to configure Log Shipping
-- for the database [INVSQLLIVE].[BPM],
-- The script needs to be run at the Primary in the context of the [msdb] database.
-------------------------------------------------------------------------------------
-- Adding the Log Shipping configuration
-- ****** Begin: Script to be run at Primary: [INVSQLLIVE] ******
usemaster
go
execsys.sp_change_log_shipping_primary_database@database ='BPM', @backup_compression= 1
go
DECLARE @LS_BackupJobIdASuniqueidentifier
DECLARE @LS_PrimaryId ASuniqueidentifier
DECLARE @SP_Add_RetCodeAsint
EXEC @SP_Add_RetCode=master.dbo.sp_add_log_shipping_primary_database
@database =N'BPM'
,@backup_directory =N'E:\SQL_LOGS\BPM'
,@backup_share =N'\\INVSQLLIVE\SQL_LOGS\BPM'
,@backup_job_name =N'LSBackup_BPM'
,@backup_retention_period = 4320
,@monitor_server =N'invsqluat'
,@monitor_server_security_mode = 1
,@backup_threshold = 1200
,@threshold_alert_enabled = 1
,@history_retention_period = 5760
,@backup_job_id = @LS_BackupJobIdOUTPUT
,@primary_id = @LS_PrimaryIdOUTPUT
,@overwrite = 1
IF(@@ERROR= 0 AND @SP_Add_RetCode= 0)
BEGIN
DECLARE @LS_BackUpScheduleUIDAsuniqueidentifier
DECLARE @LS_BackUpScheduleID ASint
EXEC msdb.dbo.sp_add_schedule
@schedule_name=N'LSBackupSchedule_INVSQLLIVE1'
,@enabled = 1
,@freq_type = 4
,@freq_interval = 1
,@freq_subday_type = 4
,@freq_subday_interval = 2
,@freq_recurrence_factor = 0
,@active_start_date = 20130405
,@active_end_date = 99991231
,@active_start_time = 0
,@active_end_time = 235900
,@schedule_uid = @LS_BackUpScheduleUIDOUTPUT
,@schedule_id = @LS_BackUpScheduleIDOUTPUT
EXEC msdb.dbo.sp_attach_schedule
@job_id = @LS_BackupJobId
,@schedule_id = @LS_BackUpScheduleID
EXEC msdb.dbo.sp_update_job
@job_id = @LS_BackupJobId
,@enabled = 1
END
EXECmaster.dbo.sp_add_log_shipping_primary_secondary
@primary_database=N'BPM'
,@secondary_server =N'invsqluat'
,@secondary_database =N'BPM'
,@overwrite = 1
-- ****** End: Script to be run at Primary: [INVSQLLIVE] ******
-- Execute the following statements at the Secondary to configure Log Shipping
-- for the database [invsqluat].[BPM],
-- the script needs to be run at the Secondary in the context of the [msdb] database.
-------------------------------------------------------------------------------------
-- Adding the Log Shipping configuration
-- ****** Begin: Script to be run at Secondary: [invsqluat] ******
DECLARE @LS_Secondary__CopyJobId ASuniqueidentifier
DECLARE @LS_Secondary__RestoreJobIdASuniqueidentifier
DECLARE @LS_Secondary__SecondaryId ASuniqueidentifier
DECLARE @LS_Add_RetCodeAsint
EXEC @LS_Add_RetCode=master.dbo.sp_add_log_shipping_secondary_primary
@primary_server=N'INVSQLLIVE'
,@primary_database =N'BPM'
,@backup_source_directory =N'\\INVSQLLIVE\SQL_LOGS\BPM'
,@backup_destination_directory =N'E:\SQL_LOGS\BPM'
,@copy_job_name =N'LSCopy_INVSQLLIVE_BPM'
,@restore_job_name =N'LSRestore_INVSQLLIVE_BPM'
,@file_retention_period = 4320
,@monitor_server =N'invsqluat'
,@monitor_server_security_mode = 1
,@overwrite = 1
,@copy_job_id = @LS_Secondary__CopyJobIdOUTPUT
,@restore_job_id = @LS_Secondary__RestoreJobId OUTPUT
,@secondary_id = @LS_Secondary__SecondaryIdOUTPUT
IF(@@ERROR= 0 AND @LS_Add_RetCode= 0)
BEGIN
DECLARE @LS_SecondaryCopyJobScheduleUID Asuniqueidentifier
DECLARE @LS_SecondaryCopyJobScheduleID ASint
EXEC msdb.dbo.sp_add_schedule
@schedule_name=N'DefaultCopyJobSchedule'
,@enabled = 1
,@freq_type = 4
,@freq_interval = 1
,@freq_subday_type = 4
,@freq_subday_interval = 2
,@freq_recurrence_factor = 0
,@active_start_date = 20130405
,@active_end_date = 99991231
,@active_start_time = 0
,@active_end_time = 235900
,@schedule_uid = @LS_SecondaryCopyJobScheduleUIDOUTPUT
,@schedule_id = @LS_SecondaryCopyJobScheduleIDOUTPUT
EXEC msdb.dbo.sp_attach_schedule
@job_id = @LS_Secondary__CopyJobId
,@schedule_id = @LS_SecondaryCopyJobScheduleID
DECLARE @LS_SecondaryRestoreJobScheduleUID Asuniqueidentifier
DECLARE @LS_SecondaryRestoreJobScheduleIDASint
EXEC msdb.dbo.sp_add_schedule
@schedule_name=N'DefaultRestoreJobSchedule'
,@enabled = 1
,@freq_type = 4
,@freq_interval = 1
,@freq_subday_type = 4
,@freq_subday_interval = 2
,@freq_recurrence_factor = 0
,@active_start_date = 20130405
,@active_end_date = 99991231
,@active_start_time = 0
,@active_end_time = 235900
,@schedule_uid = @LS_SecondaryRestoreJobScheduleUIDOUTPUT
,@schedule_id = @LS_SecondaryRestoreJobScheduleIDOUTPUT
EXEC msdb.dbo.sp_attach_schedule
@job_id = @LS_Secondary__RestoreJobId
,@schedule_id = @LS_SecondaryRestoreJobScheduleID
END
DECLARE @LS_Add_RetCode2 Asint
IF(@@ERROR= 0 AND @LS_Add_RetCode= 0)
BEGIN
EXEC @LS_Add_RetCode2=master.dbo.sp_add_log_shipping_secondary_database
@secondary_database=N'BPM'
,@primary_server =N'INVSQLLIVE'
,@primary_database =N'BPM'
,@restore_delay = 0
,@restore_mode = 0
,@disconnect_users = 0
,@restore_threshold = 20
,@threshold_alert_enabled = 1
,@history_retention_period = 5760
,@overwrite = 1
END
IF(@@error= 0 AND @LS_Add_RetCode= 0)
BEGIN
EXEC msdb.dbo.sp_update_job
@job_id = @LS_Secondary__CopyJobId
,@enabled = 1
EXEC msdb.dbo.sp_update_job
@job_id = @LS_Secondary__RestoreJobId
,@enabled = 1
END
-- ****** End: Script to be run at Secondary: [invsqluat] ******
A solution to this will get a bottle of single malt whiskey delivered anywhere in the world.
Martin
Martin Peter Clarke