Below are the key requirements for SQL Server log shipping and a step-by-step setup outline using SQL Server Management Studio (SSMS) and Transact-SQL.
Core requirements for log shipping
- SQL Server version and roles
- Supported on SQL Server (on-premises or on Azure VMs).
- Optional third instance can be used as a monitor server.
- The account configuring log shipping must be a member of the sysadmin fixed server role.
- Database recovery model
- The primary database must use FULL or BULK-LOGGED recovery model.
- Switching the primary database to SIMPLE recovery will cause log shipping to stop functioning.
- Secondary server and database
- The secondary server must be the same or higher SQL Server version than the primary.
- A secondary database must be initialized from a full backup of the primary, restored with
NORECOVERYorSTANDBY.
- Backup share / file storage
- A network share is required where transaction log backups from the primary are written.
- Example on Windows:
\\<primaryserver>\tlogsfor local folderC:\data\tlogs\. - On Azure VMs, this can be an Azure Files share such as
\\yourstorageaccount.file.core.windows.net\log-shipping\log-backups.
- Security and permissions
- The SQL Server service account on the secondary must have read/change permissions on the backup share so the copy job can read and move files.
- In multi-domain environments, two-way trusts are recommended; if not possible, use pass-through security as described for LocalSystem scenarios.
- For monitor server connections, either Windows authentication or SQL authentication can be used. If SQL authentication is chosen, a
log_shipping_monitor_probelogin is created and SQL Server must be configured for mixed mode.
- SQL Server Agent
- SQL Server Agent must be running on primary, secondary, and monitor (if used) because log shipping uses Agent jobs for backup, copy, restore, and alerting.
- Networking and name resolution
- Servers must be able to reach each other and the backup share over the network.
- DNS and name resolution must work correctly so UNC paths and server names resolve (misconfigured DNS can cause copy/restore failures).
- Optional monitor server
- A separate SQL Server instance can be used as a monitor server to track status and raise alerts if backup/copy/restore do not occur within thresholds.
Detailed setup using SQL Server Management Studio (GUI)
These steps describe a typical configuration using SSMS.
- Prepare the primary database
- Ensure the database is in FULL or BULK-LOGGED recovery model.
- Take a full backup of the primary database and restore it on the secondary with
NORECOVERY(or let SSMS do this in step 14).
- Create and configure the backup share
- On or accessible from the primary server, create a folder for log backups, for example
C:\data\tlogs\. - Share it as a UNC path, for example
\\<primaryserver>\tlogs. - Grant read/change permissions on this share to the SQL Server service account running on the secondary server.
- On or accessible from the primary server, create a folder for log backups, for example
- Enable log shipping on the primary database
- In SSMS, connect to the primary instance.
- Right-click the primary database → Properties.
- Under Select a page, choose Transaction Log Shipping.
- Check Enable this as a primary database in a log shipping configuration.
- Configure transaction log backups
- Under Transaction log backups, select Backup Settings.
- In Network path to the backup folder, enter the UNC path to the backup share (for example
\\<primaryserver>\tlogsor an Azure Files path). - If the backup folder is on the primary server, specify the local path in Backup folder (for example
C:\data\tlogs\). - Configure Delete files older than to control retention of log backup files.
- Configure Alert if no backup occurs within to define the alert threshold.
- Review the Backup job schedule and adjust if needed via Schedule (frequency and interval for log backups).
- Optionally configure backup compression: Use default, Compress backup, or Do not compress backup.
- Select OK to save backup settings.
- Add and configure the secondary server
- In the same Transaction Log Shipping page, under Secondary server instances and databases, select Add.
- Select Connect and connect to the secondary SQL Server instance.
- In Secondary Database, choose an existing database or type a new database name (commonly a new database initialized from the primary).
- Initialize the secondary database
- On the Initialize Secondary Database tab, choose one of:
- Generate a full backup of the primary database and restore it on the secondary (SSMS does this automatically), or
- Restore an existing backup that was already taken and restored with
NORECOVERY.
- Note that if SSMS initializes the secondary, the data/log files are placed in the same location as the
masterdatabase on the secondary, which may differ from the primary.
- On the Initialize Secondary Database tab, choose one of:
- Configure copy job on the secondary
- Go to the Copy Files tab.
- In Destination folder for copied files, specify a local folder on the secondary where log backups will be copied.
- Review the Copy job schedule and adjust via Schedule so it runs frequently enough to keep up with backups.
- Configure restore job on the secondary
- Go to the Restore tab.
- Under Database state when restoring backups, choose:
- No recovery mode (database not readable, ready for quick failover), or
- Standby mode (read-only access between restores; users are disconnected during restore). Note: Standby mode is only allowed when primary and secondary major versions are the same; if the secondary is a higher major version, only No recovery mode is allowed.
- If using Standby, choose whether to disconnect users during restore.
- Optionally set Delay restoring backups at least to intentionally lag restores.
- Set Alert if no restore occurs within to define restore alert thresholds.
- Review the Restore job schedule and adjust via Schedule so it roughly matches the backup schedule.
- Select OK to save secondary settings.
- Configure monitor server (optional but recommended)
- Back in the Transaction Log Shipping page, under Monitor server instance, check Use a monitor server instance.
- Select Settings.
- Select Connect and connect to the monitor SQL Server instance.
- Under Monitor connections, choose the authentication method (Windows or SQL) for backup, copy, and restore jobs to connect to the monitor.
- Under History retention, set how long to retain log shipping history.
- Select OK.
- Note: To add a monitor later, the configuration must be removed and recreated with a monitor.
- Finalize configuration
- In the Database Properties dialog, select OK to start the configuration.
- SSMS will create and enable the backup, copy, and restore jobs (and alert job if a monitor is used).
Setup using Transact-SQL (high-level sequence)
For scripted deployments, use the log shipping stored procedures in this order:
- Initialize secondary database
- Take a full backup of the primary and restore it on the secondary with
NORECOVERY.
- Take a full backup of the primary and restore it on the secondary with
- Configure primary
- On the primary, execute
sp_add_log_shipping_primary_databaseto register the primary database and backup settings. This returns the backup job ID and primary ID. - Use
sp_add_jobscheduleto create a schedule for the backup job. - On the monitor server, run
sp_add_log_shipping_alert_jobto create the alert job. - Enable the backup job on the primary.
- On the primary, execute
- Configure secondary
- On the secondary, run
sp_add_log_shipping_secondary_primarywith details of the primary server and database. This returns the secondary ID and the copy and restore job IDs. - Use
sp_add_jobscheduleto schedule the copy and restore jobs. - Run
sp_add_log_shipping_secondary_databaseto register the secondary database.
- On the secondary, run
- Link primary and secondary metadata
- On the primary, run
sp_add_log_shipping_primary_secondaryto add information about the secondary to the primary configuration.
- On the primary, run
- Enable jobs on secondary
- Enable the copy and restore jobs on the secondary.
References:
- Configure log shipping (SQL Server)
- Configure log shipping for SQL Server on Azure VMs
- Configure security for SQL Server log shipping
- Log Shipping and Replication (SQL Server)
- Database Mirroring and Log Shipping (SQL Server)
- SQL Server log shipping in linux issues with restore job cannot retrieve restore settings - Microsoft Q&A
- Changing Custom 445 Port for SQL Log Shipping - Microsoft Q&A
- I have a 2019 SQL database which is the primary, I want to set up a secondary server using logshipping. What is the highest version on SQL server I can install. Upgrading the primary is not an option. - Microsoft Q&A
- Is there any better disaster recovery than Transactional Replication? - Microsoft Q&A