ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

How To Set Up Transaction Log Shipping in Microsoft SQL Server 2008R2

Updated on January 6, 2014

Introduction

Microsoft SQL Server Log Shipping provides a means of creating a warm standby SQL server database on another server. This is one method that can be used in a site disaster recovery solution.

The servers that are involved in Log Shipping can be in distant cities.

What is Transaction Log Shipping

Firstly, let’s understand what a transaction log is. A Microsoft SQL Server Database has typically a database file and a transaction log file. SQL transactions are executed in memory and get written to the log file. Every transaction and every database modification gets written to the transaction log file.

Transaction Log Shipping is basically the method for backing up a transaction log file at regular intervals and copying those backup files to a destination server, and restoring those backup files at regular intervals.

Requirements

You need at least two servers running Microsoft SQL Server.

The database that needs to be “shipped” must be configured to use the Full recovery model.

In this model, the transaction logs are not truncated after a full backup. The transaction logs are required to be backed up separately. In this way, it is possible to restore to a point in time by restoring the logs if need be.

However, when you are going to be doing Log Shipping, you MUST turn off any other Transaction Log backups for the database, otherwise it will interfere with the sequence of the transaction log backups.

Setting Up

  1. Install the “primary” SQL Server on Subnet A, in location A.
  2. Install the “secondary” SQL server in subnet B, in location B.

On the primary server:

  1. Select the database that is going to be “shipped”.
  2. Create a folder on the drive of the SQL Server so that the Logs can be generated in one of the sub folders.
  3. Create a Windows account that has the same name as the account that is used for the SQL Agent service on the secondary SQL server. Make sure you use the same password.
  4. Share the folder and assign appropriate NTFS security permissions. Give the account above Read access permissions.
  5. Modify firewall rules so that the host on Subnet B will be able to map to the shared folder of the host in Subnet A.
  6. I find that I need to allow NB Session (TCP Port 137), ND Datagram, SMB . NB-name to be able to net use into \\servername\sharename .


Full Recovery Model

Set the Database to Full Recovery Model

Right click and select Properties of the Database, and select Options. Make sure the recovery model is set to Full.

Hit OK.

Restore and Leave as Read Only

Initialize the Secondary Database

On the Primary server, make a Full Backup of the database that will be "shipped".

Transfer the backup file to the Secondary server and Restore the database.

Give the database a name. It is best to use the same name as the original since it will save time when you need to turn this “warm standby” server to a live one if the database already has the correct name. This is especially true if you have many databases on this server.

Click on Options and make sure Leave the Database in Read Only mode is selected before you complete the Restore. You can choose "Leave the database non-operational..." but then you won't be able to read the data in the tables, etc.. I find putting the Database in Read Only mode would be ideal in a lot of situations.

Configuring the Primary Server for Log Shipping

On the primary server, Right Click the Database that is going to be shipped and select Properties.

Select Transaction Log Shipping.

Tick the Enable this as a primary database in a log shipping configuration

Click on Backup Settings.

For the network path, use a UNC path and the hostname should be something that can be resolved externally from this subnet (i.e. from the internet). This should be a path to the folder that will contain the transaction log backups to be shipped.

For the backup folder location, enter the path to the same folder above but using the drive:\folder notation. You can use the default values for the other values.

Click on Schedule.

Change the values to the desired frequency for the transaction log backups. Hit OK, and Hit OK again.

Configuring the Secondary Server for Log Shipping

In the Secondary Server instances and Databases section, click on Add.

Click on Connect.

Then enter the details of the secondary server in the Connect to Server dialog box.


Configuring Secondary Database Settings

After you have successfully connected to the secondary server, you will get the following screen.

Because we have already restored a copy of the full backup, we can select No, the secondary database is initialized.

Click on the Copy Files tab.

Enter a local folder path that is on the secondary server in which the backup files will be copied to from the primary server.

Click Schedule, and you may leave it on the default settings. Click OK.

Click on Restore Transaction Log tab. .

Select Standby mode, and tick Disconnect Users in the database when restoring backups

Click On Schedule. You can use the default settings.

Hit OK. Hit OK.

In this article we will not be using a monitor server.

Finished

Once you have configured the Secondary server, you will see the following screen. Press OK again, and the SQL jobs will be created on the Secondary server.

The jobs are :

1) Copy the transaction log backup files from the Primary server to a local folder

2) Restore the transaction log backup files from the local folder.

Transaction Log Shipping have now been set up.

Comments

    0 of 8192 characters used
    Post Comment

    • jabelufiroz profile image

      Firoz 

      5 years ago from India

      Good for beginners. Voted up.

    working

    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, hubpages.com uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at: https://hubpages.com/privacy-policy#gdpr

    Show Details
    Necessary
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the googleapis.com or gstatic.com domains, for performance and efficiency reasons. (Privacy Policy)
    Features
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Marketing
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Statistics
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)