July 18, 2017

Five Reasons Why Log Shipping Should Be Used

SQL Server comes with several options to keep your data highly available. Today we are going to cover five different reasons why Transactional Log Shipping should be one of your best tools in your SQL Server DBA Toolbelt. 

Validates Transactional Log Backups

Your last line of defense in any SQL Server Disaster Plan is recovering backups.  To be able to recover to a point of failure you have to leverage transactional log backups while using the full or bulk-logged recovery model.  Every transactional log backup has to be restored one by one in-sync after your last full and differential backups to recover to the point of failure.  Wouldn’t it be nice if you could automate restoring every log backup so you knew you had good backups? Transactional log shipping is the easiest way to complete this task. It also gives you a copy you can easily bring online without having to restore all of your backups.

Secondary Copy of Transactional Log Backups

We already mentioned that the last line of defense in any disaster recovery plan is restoring backups.  Wouldn’t it be nice if you had copies of your transactional log backups on multiple servers? Maybe even multiple data centers?  Well, transactional log shipping also helps automate this as well. The second step in transactional log shipping is copying your transactional log backups. Now you just have to make sure your full and differential backups are copied.

Recover Data Quickly for Very Large Tables

Have you ever forgotten to add or highlight the where condition while you are running a delete or update statement? If you haven’t, do not be surprised if it happens in the future by you or someone else in your company.  This can be an extremely painful recovery process if it happens against tables with terabytes of data.  With all other SQL Server High Availability features like mirroring, availability groups, and failover cluster instances, the data changed almost instantly so you couldn’t use this solution to recover.  You now have bad data that is highly available.

With transactional log shipping, you can delay the restore time so if you discover the changed data by mistake you could disable the SQL Agent Jobs and pull the missing data in parallel of implementing your plan to get the rest of the data from the last restore.  This can bring most of your data online quickly while you are restoring a very large backup.  The best part is you don’t have to recover your log shipping copy.  You can put it in standby mode and read data while it’s still in a state where you can continue to restore transactional backups (more on this below).

Poor Person’s Reporting Copy

Would it be nice to have a readable copy of your database that you could use for reporting? Even if you have Web Edition. Transactional log shipping gives you this ability even though you might not know that it exists.  When you are restoring the transactional log backups with transactional log shipping you have two options.  The transactional log backups can be restored in standby mode which allows you to read data in-between transactional log backup restores. You can also use the default, which is no recovery.  This doesn’t allow any access to read the backups. This is just like your mirror copy in database mirroring (without snapshot copy on enterprise edition).

There is one big catch with using standby as your recovery option.  You have to specify if you want to delay restores if an active session exists or pick to terminate the connections to force the transactional backup restore.

Improve Downtime for Migrations and Upgrades

When you migrate a database or upgrade using the side by side option you have to have another copy of the database.  Ideally, the source and destination would be identical at the point of implementing the migration.  With very large databases this could require a very large downtime so backup and restore, or detach and attach, are good options unless you have a very large maintenance window. Seeding the data so that only a small amount of changed data needs to be synced is ideal.  Log shipping is an excellent way to do this especially if you have multiple copies that need to be synced for implementing availability groups.  Here is how we made a 60TB database highly available for an Availability Group implementation with zero downtime. Example

My New Log Shipping Feature Request 

I know, you are already thinking that Log Shipping has been around forever and it doesn’t need any new features, but I got one.  In SQL Server 2016 Direct Seeding was added to streamline how the initial sync occurs for Availability Groups. I would like to see this same feature extended for log shipping so we have an easy automated option to perform the initial sync for transactional log shipping.

5 Responses to “Five Reasons Why Log Shipping Should Be Used”

  1. Hi,

    Thanks for this post.

    I have an SQL Server 2008 R2 where I can’t find where I change the log backup of a Log Shipping to be compressed.

    Can I do that?

    The log shipping is working, but with a large log backup.

    If a run a log backup with compression manually in a database, works perfectly.

  2. nathan.barron@employbridge.com

    I like this post a lot, and even with AG setup this is valid as it validates your tlog backups… One question I have though. When electing to put the DB in readonly… does anyone else see an issue with it failing to apply tlogs seemingly randomly? The fix I read about and used was to apply the last tlog manually… but I don’t like that the process fails as frequently as it does… I have 2 colleagues that saw the same in other shops. Thoughts?

    • JohnSterrett

      Hi Nathan,

      From time to time I will see occasions where the restore job in log shipping doesn’t find a transactional log backup that was copied successfully. This isn’t directly related to log shipping with an Availability Group or having a secondary copy changing between norecovery and standby either. This is where your log shipping monitoring solution is key. We will talk about this in the next blog post.

      As you mentioned you would have to restore the log backup manually and then you should see the remaining transactional log backups get restored during your next execution of the restore job.

      Regards,
      John

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.