Methods to Back Up the Tail of the Transaction Log
Here are the two methods you can use to back up the Tail log backup:
Step 1: Using SQL Server Management Studio (SSMS)
a02ef93dadf3287c621a52919445197af0599e95fd43bc576829416abc9c7
b82_backup_set.png692×625 28.4 KB
Follow these steps to take tail-log backup using SSMS:
Step 1: Connect to an appropriate instance of the SQL Server Database
Engine.
Step 2: In Object Explorer window, expand Databases, right-click the
damaged database, and then click Back Up.
Step 3: In ‘Back Up Database’ dialog box, do the following:
1. Verify the database name in the Database list box and the recovery
model as FULL or BULK_LOGGED.
2. In the ‘Backup type:’ list box, select Transaction Log.
3. Leave the ‘Copy-only Backup’ checkbox unchecked.
4. In the ‘Backup set’ section, the default backup set name is displayed in
the ‘Name’ text box. Next, enter description for the tail-log backup.
Note: You can also enter a different name that you want for the backup
set.
5. Click ‘Backup Options’ and specify when the backup set will expire by
choosing any of these options:
• If you want the backup set to expire after a specific period of time, click
‘After’ and select the number of days from ‘0 to 99999’ after which the set
will expire. Choose ‘0’ if you do not want the backup set to expire.
• If you want the backup set to expire on a specific date, click the On
option, and select the date on which the set will expire.
• Choose the backup destination by selecting either Disk or Tape option.
Note: Click ‘Add’ for selecting the paths of up to 64 disk or tape drives
having a single media set. The path will be displayed in the ‘Backup to’ list
box. Click ‘Remove’ if you want to remove a backup destination, and click
‘Contents’ to view the backup contents.
Step 4: Click on the Options tab under ‘Select a page’, select any of the
Overwrite Media options:
1. Choose “Back up to the existing media set” option, and then select
either “Append to the existing backup set” or “Overwrite all existing
backup sets”.
Note: Optionally, you can choose the “Check media set name and backup
set expiration” for verifying the media set and backup set expiration date
and time. Optionally, you can specify a name for the Media set. If no name
is entered, a media set with a blank name gets created.
2. Choose “Back up to a new media set, and erase all existing backup
sets” option. For this, enter a name for the ‘New media set name’. You
can also provide description of the media set in the ‘New media set
description’ box.
3. In the “Reliability” section, select any of these options:
• Verify backup when finished.
• Perform checksum before writing to media
• Continue on checksum error
4. In the “Transaction log” section, check the “Back up the tail of the log,
and leave database in the restoring state” option.
Step 2: Using Transact-SQL
For creating tail-log backup by executing T-SQL query, follow these steps:
Step 1: Run the following command to take a tail-log backup:
BACKUP LOG <database_name> TO <backup_device>
WITH NORECOVERY; NO_TRUNCATE;
This command helps recover the db as part of the last RESTORE LOG
statement. In other words, the command will capture the transaction log
entries that aren’t backed up and will put the database into the
RESTORING state to avoid any new data from being added to the T-log.
Step 2: Restore a Full database backup ‘WITH NORECOVERY’:
RESTORE DATABASE <database_name> FROM <backup_device>
WITH NORECOVERY;
Step 3: You can also choose to restore any Differential backups using the
“WITH NORECOVERY” option. This optional step can help you have less T-
log restores to perform.
RESTORE DATABASE <database_name> FROM <backup_device>
WITH NORECOVERY;
Step 4: Restore your transaction log backup, including the tail-log backup
(created in Step 1), using “WITH NORECOVERY” option:
RESTORE LOG <database_name> FROM <backup_device>
WITH NORECOVERY;
Step 5: Finally, bring your database back online by executing this
command:
RESTORE DATABASE <database_name>
WITH RECOVERY;
After performing these steps, your database will be available again
containing all the log entries.
Step 3: What to do if the Log backup is corrupt?
You cannot perform tail-log backup if the log backup is corrupted or
damaged. In such a scenario, you will lose any transactions committed
after the latest log backup. To prevent data loss, using Stellar Toolkit for
MS SQL 2 can come in handy. The toolkit comprises tools that helps repair
corrupt SQL database and restore the database with all its data intact. It
can also help recover data from a corrupted SQL backup file (.bak).
There are restore scenarios that do not require performing tail-log
backups (check out the references for more information). However,
creating tail-log backups is a useful feature for the users who want to
recover everything during a database restore operation. But, keep in
mind, you cannot take a tail-log backup if the transaction log backup is
damaged or corrupted. In that case, try using a SQL repair tool that allows
restoring the SQL database to its original state. Such tool can also help
recover all the database objects without any data loss.