SQL Flow Field Guide

sys.sp_add_log_shipping_primary_database

Check SQL Server version support in the source

Sets up the primary database for a log shipping configuration, including the backup job, local monitor record, and remote monitor record.

What changes

Input
Not stated in the Microsoft summary.
Output or change
Sets up the primary database for a log shipping configuration, including the backup job, local monitor record, and remote monitor record.

Syntax at a glance

sys.sp_add_log_shipping_primary_database
    [ @database = ] N'database'
    , [ @backup_directory = ] N'backup_directory'
    , [ @backup_share = ] N'backup_share'
    [ , [ @backup_job_name = ] N'backup_job_name' ]
    [ , [ @backup_retention_period = ] backup_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' ]
    [ , [ @backup_threshold = ] backup_threshold ]
    [ , [ @threshold_alert = ] threshold_alert ]
    [ , [ @threshold_alert_enabled = ] threshold_alert_enabled ]
    [ , [ @history_retention_period = ] history_retention_period ]
    [ , [ @backup_job_id = ] 'backup_job_id' OUTPUT ]
    [ , [ @primary_id = ] 'primary_id' OUTPUT ]
    [ , [ @overwrite = ] overwrite ]
    [ , [ @ignoreremotemonitor = ] ignoreremotemonitor ]
    [ , [ @backup_compression = ] backup_compression ]
    [ , [ @primary_server_with_port_override = ] N'primary_server_with_port_override' ]
    [ , [ @primary_connection_options = ] N'primary_connection_options' ]
    [ , [ @monitor_connection_options = ] N'monitor_connection_options' ]
[ ; ]

Work example

Sets up the primary database for a log shipping configuration, including the backup job, local monitor record, and remote monitor record.

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.