Step By Step Configuration of Log Shipping in SQL Server

Andrew Jackson | Modified: November 29th, 2018 | Log Shipping |

What is SQL Server Log Shipping ?

Log shipping in SQL Server provides a disaster recovery solution at the database level. A log-shipping configuration involves two or more SQL Server instances and copying of a transaction log file from one SQL Server instance to another. Enabling Log shipping will automatically transfer transaction log files and restore it across SQL servers. In the article, we will be discussing step by step procedure for configuring Log Shipping in SQL Server.

Log Shipping is a basic level SQL Server high availability solution that provides automated backup and restore process by creating another copy of SQL Database for failover. Feature of Log Shipping is available in all SQL Server Editions except the Express edition. It is method of copying a database backup and subsequent transaction log backups from source server and restoring transaction log backups on one or more destination servers.

Configuring Log Shipping in SQL Server – Prerequisites

There are some minimum requirements for configuring Log Shipping in SQL Server. First, one must have sysadmin rights and permissions on the Server to set up the log shipping. The prerequisites for setting up Log shipping are as follows:

  • The version of SQL Server must be at least 2005 or later versions
  • Works on standard, workgroup or Enterprise SQL Server editions
  • Same case sensitivity settings should be present in the servers that in involved in log shipping
  • Primary database must be set in full recovery or bulk-logged recovery model. Using Simple recovery model will stop the Log shipping to function
  • Create a shared folder to copy transaction log files& make it available to secondary server
  • The SQL Server Agent Service should be configured properly

Enable Log Shipping using SQL Server Management Studio

The steps for configuring log shipping in SQL Server using SQL Server Management Studio are-

  1. Open SQL server Management Studio & Connect to primary server ‘WINDOWS2’
  2. Open SQL Server

  3. Select the database and right-click to view the properties. Database properties window will be opened. Click on Options to ensure that the recovery model is set to full or bulk-logged model.
  4. Recovery Model

  5. From the Properties windows, select Transaction Log Shipping option and tick the checkbox of Enable this as primary database in a log shipping configuration
  6. Transaction Log Shipping configuration

  7. To configure & schedule transaction log backup, select Backup settings. We can create backup either on a network specifying network path or local system specifying local folder path. We will type the name of backup job and schedule the backup. Click OK.
  8. Backup settings

  9. We will now configure secondary instance and database. Click on Addbutton and add multiple servers if desired for setting one or more server log shipping.
  10. add

  11. After selecting the secondary server and connecting to the database, it will be displayed in secondary databases column. After clicking on Add, secondary database settings window will be opened. We can change the settings in three places.
    Initialize Secondary Database
    There are two options available to restore backup into secondary database. We can either generate a full backup of primary database and restore it to secondary server or use existing backup of primary database and restore it on secondary server. We have selected the first option.

    Initialize Secondary Database

    Copy files
    We will define the destination folder for copied T-Log backup files creating the copy job and schedule job.

    Copy files

    Restore Transaction Log
    We will specify the database restoring state information and restore schedule after creating job on secondary server. Selecting Standby Mode will make Secondary database in read only mode and user can only read the data.
  12. Restore Transaction Log

  13. We can use Log Shipping Monitor service that will give us alert if there is any failure. It is an optional feature. Tick the checkbox of use a monitor service instance
    Monitor Service Instance
  14. Click on Settings after checking the box for Monitor service. Connect the server instance Windows\secondary and Click OK.
  15. Windows\secondary

  16. We can see the Log Shipping is successfully configured in SQL Server.
  17. configured SQL Server Log Shipping

Conclusion

In the above article, we have thoroughly discuss the SQL Server log shipping, which is used as a disaster recovery solution. Configuring Log shipping in SQL Server is not difficult if we follow the step by step procedure given in the article. We have explain the steps to configure log shipping in SQL server using SQL Server Management Studio (SSMS). Even though it can also be configured using Transact-SQLs, most of users prefer using SSMS. Log shipping is an important feature in SQL Server that is easy to set up and maintain.