sp_add_log_shipping_secondary_primary (Transact-SQL)
Sets up the primary information, adds local and remote monitor links, and creates copy and restore jobs on the secondary server for the specified primary database.
sp_add_log_shipping_secondary_primary
[ @primary_server = ] 'primary_server',
[ @primary_database = ] 'primary_database',
[ @backup_source_directory = ] 'backup_source_directory' ,
[ @backup_destination_directory = ] 'backup_destination_directory'
[ @copy_job_name = ] 'copy_job_name'
[ @restore_job_name = ] 'restore_job_name'
[, [ @file_retention_period = ] 'file_retention_period']
[, [ @monitor_server = ] 'monitor_server']
[, [ @monitor_server_security_mode = ] 'monitor_server_security_mode']
[, [ @monitor_server_login = ] 'monitor_server_login']
[, [ @monitor_server_password = ] 'monitor_server_password']
[, [ @copy_job_id = ] 'copy_job_id' OUTPUT ]
[, [ @restore_job_id = ] 'restore_job_id' OUTPUT ]
[, [ @secondary_id = ] 'secondary_id' OUTPUT]
sp_add_log_shipping_secondary_primary must be run from the master database on the secondary server. This stored procedure does the following:
-
Generates a secondary ID for the specified primary server and primary database.
-
Does the following:
-
Adds an entry for the secondary ID in log_shipping_secondary using the supplied arguments.
-
Creates a copy job for the secondary ID that is disabled.
-
Sets the copy job ID in the log_shipping_secondary entry to the job ID of the copy job.
-
Creates a restore job for the secondary ID that is disabled.
-
Set the restore job ID in the log_shipping_secondary entry to the job ID of the restore job.
-
This example illustrates using the sp_add_log_shipping_secondary_primary stored procedure to set up information for the primary database AdventureWorks2012 on the secondary server.
EXEC master.dbo.sp_add_log_shipping_secondary_primary @primary_server = N'TRIBECA' ,@primary_database = N'AdventureWorks' ,@backup_source_directory = N'\\tribeca\LogShipping' ,@backup_destination_directory = N'' ,@copy_job_name = N'' ,@restore_job_name = N'' ,@file_retention_period = 1440 ,@monitor_server = N'ROCKAWAY' ,@monitor_server_security_mode = 1 ,@copy_job_id = @LS_Secondary__CopyJobId OUTPUT ,@restore_job_id = @LS_Secondary__RestoreJobId OUTPUT ,@secondary_id = @LS_Secondary__SecondaryId OUTPUT GO
