TAIL-LOG Backup in SQL Server Step by Step Tutorial

0
237

In this tutorial, we will discuss how to take a tail-log backup in SQL Server. 

A tail-log backup is taken when the database is in an operational state and no full or differential backups have been taken for some time. This type of backup captures all of the log records that have not yet been backed up, up to the point of the current backup operation.

Tail-log backups are useful in several scenarios, such as:

  • Restoring a database to a specific point in time
  • Recovering from a media failure
  • Performing database replication

To take a tail-log backup, we will use the BACKUP LOG command. This command has the following syntax:

  • BACKUP LOG Database Name
  • TO Disk File
  • WITH NOFORMAT, 
  • NOINIT, 
  • NAME = ‘BackupLog’, 
  • SKIP, 
  • REWIND, 
  • NOUNLOAD, 
  • STATS = 10
  • GO

The above example will take a tail-log backup of the database named “DatabaseName” to the disk file “DiskFile”. 

The other options used in this command are discussed below.

  • NOFORMAT: This option indicates that the backup should not be formatted. This is useful when the database will be restored to a different server.
  • NOINIT: This option prevents the backup from being overwritten if it already exists. This is useful when multiple backups are being taken and you want to keep all of the backups.
  • NAME: This option gives the backup a name. This is useful for identification purposes.
  • SKIP: This option skips any intervening transaction log backups that have been taken since the last full or differential backup. This is useful when you want to take a tail-log backup but do not have all of the previous transaction log backups.
  • REWIND: This option rewinds the tape after taking the backup. This is useful when multiple backups are being taken and you want to keep all of the backups on one tape.
  • NOUNLOAD: This option prevents the tape from being unloaded after taking the backup. This is useful when multiple backups are being taken and you want to keep all of the backups on one tape. Check RemoteDBA.com.
  • STATS: This option specifies the level of detail to be returned in the backup operation results. The default is 10, which returns information about the backup operation progress.

Once the BACKUP LOG command has been executed, the database will be backed up and the transaction log will be truncated. This means that any log records that have been backed up will no longer be available and cannot be rolled back. Therefore, it is important to make sure that all transactions have been committed or rolled back before taking a tail-log backup.

If you need to rollback any transactions after taking a tail-log backup, you can use the STOPAT MARK command. This command will stop the database at a specific log mark and all transactions up to that point will be available for rollback. 

In this tutorial, we will show you how to perform a TAIL-LOG backup in SQL Server. 

This type of backup is useful when you want to backup the transaction log without interrupting the database operation.

Prerequisites:

  • You must have a backup of the full database before performing a TAIL-LOG backup.
  • The database must be in FULL or BULK_LOGGED recovery model.
  • Make sure that the disk space is available for storing the transaction log backup file.
  • You must have sufficient permissions to perform a TAIL-LOG backup.

Steps:

1) Open SQL Server Management Studio and connect to the database server.

2) Right-click on the database that you want to backup and select Tasks > Back Up….

3) In the Backup Database dialog box, set the following options:

  • Backup type: Transaction Log
  • Destination: Disk
  • Checkmark Verify backup when finished

4) Click OK to start the backup process.

5) Once the backup is complete, click Close.

You have now successfully performed a TAIL-LOG backup in SQL Server.

Conclusion:

In this tutorial, you have learned how to perform a TAIL-LOG backup in SQL Server. This type of backup is useful when you want to backup the transaction log without interrupting the database operation.