Tail log backups capture the tail of the log even if the database is offline, damaged, or missing data files. This might cause incomplete metadata from the restore information commands and msdb. However, only the metadata is incomplete; the captured log is complete and usable.
If a tail-log backup has incomplete metadata, in the backupset table, has_incomplete_metadata is set to 1. Also, in the output of RESTORE HEADERONLY, HasIncompleteMetadata is set to 1.
To create a tail log backup, use below script
BACKUP LOG [DB Name]
TO [TLog_Device_Location]
WITH NO_TRUNCATE;
GO
Scenarios That Require a Tail-Log Backup
The following table summarizes the BACKUP NORECOVERY and CONTINUE_AFTER_ERROR options.
BACKUP LOG option Comments
Use NORECOVERY whenever you intend to continue with a restore operation on the database. NORECOVERY takes the database into the restoring state. This guarantees that the database does not change after the tail-log backup. The log will be truncated unless the NO_TRUNCATE option or COPY_ONLY option is also specified.
NOTE: Avoid using NO_TRUNCATE, except when the database is damaged.
CONTINUE_AFTER_ERROR Use CONTINUE_AFTER_ERROR only if you are backing up the tail of a damaged database.
When you use back up the tail of the log on a damaged database, some of the metadata ordinarily captured in log backups might be unavailable.
If a tail-log backup has incomplete metadata, in the backupset table, has_incomplete_metadata is set to 1. Also, in the output of RESTORE HEADERONLY, HasIncompleteMetadata is set to 1.
To create a tail log backup, use below script
BACKUP LOG [DB Name]
TO [TLog_Device_Location]
WITH NO_TRUNCATE;
GO
Scenarios That Require a Tail-Log Backup
- If the database is online and you plan to perform a restore operation on the database, begin by backing up the tail of the log. To avoid an error for an online database, you must use the ... WITH NORECOVERY option of the BACKUP Transact-SQL statement.
- If a database is offline and fails to start and you need to restore the database, first back up the tail of the log. Because no transactions can occur at this time, using the WITH NORECOVERY is optional.
- If a database is damaged, try to take a tail-log backup by using the WITH CONTINUE_AFTER_ERROR option of the BACKUP statement.
The following table summarizes the BACKUP NORECOVERY and CONTINUE_AFTER_ERROR options.
BACKUP LOG option Comments
Use NORECOVERY whenever you intend to continue with a restore operation on the database. NORECOVERY takes the database into the restoring state. This guarantees that the database does not change after the tail-log backup. The log will be truncated unless the NO_TRUNCATE option or COPY_ONLY option is also specified.
NOTE: Avoid using NO_TRUNCATE, except when the database is damaged.
CONTINUE_AFTER_ERROR Use CONTINUE_AFTER_ERROR only if you are backing up the tail of a damaged database.
When you use back up the tail of the log on a damaged database, some of the metadata ordinarily captured in log backups might be unavailable.
Comments
Post a Comment