SQL Flow Field Guide

sys.sp_add_log_shipping_secondary_primary

Check SQL Server version support in the source

Sets up the primary information, adds local and remote monitor links, and creates copy and restore jobs on the secondary server.

What changes

Input
Not stated in the Microsoft summary.
Output or change
Sets up the primary information, adds local and remote monitor links, and creates copy and restore jobs on the secondary server.

Syntax at a glance

sys.sp_add_log_shipping_secondary_primary
    [ @primary_server = ] N'primary_server'
    , [ @primary_database = ] N'primary_database'
    , [ @backup_source_directory = ] N'backup_source_directory'
    , [ @backup_destination_directory = ] N'backup_destination_directory'
    [ , [ @copy_job_name = ] N'copy_job_name' ]
    [ , [ @restore_job_name = ] N'restore_job_name' ]
    [ , [ @file_retention_period = ] file_retention_period ]
    [ , [ @monitor_server = ] N'monitor_server' ]
    [ , [ @monitor_server_security_mode = ] monitor_server_security_mode ]
    [ , [ @monitor_server_login = ] N'monitor_server_login' ]
    [ , [ @monitor_server_password = ] N'monitor_server_password' ]
    [ , [ @copy_job_id = ] 'copy_job_id' OUTPUT ]
    [ , [ @restore_job_id = ] 'restore_job_id' OUTPUT ]
    [ , [ @secondary_id = ] 'secondary_id' OUTPUT ]
    [ , [ @overwrite = ] overwrite ]
    [ , [ @ignoreremotemonitor = ] ignoreremotemonitor ]
    [ , [ @secondary_connection_options = ] '<key_value_pairs>;[...]' ]
    [ , [ @monitor_connection_options = ] '<key_value_pairs>;[...]' ]
[ ; ]

Work example

Sets up the primary information, adds local and remote monitor links, and creates copy and restore jobs on the secondary server.

Write a proposed call on paper. Name the target, required permission, expected change, and recovery step before any lab use.

Check your work What can this procedure change or start, and what permission does it need?

Open Microsoft Learn for full syntax, permissions, and details for your version.