gebeurtenis
31 mrt, 23 - 2 apr, 23
De grootste SQL-, Fabric- en Power BI-leerevenement. 31 maart – 2 april. Gebruik code FABINSIDER om $ 400 te besparen.
Zorg dat u zich vandaag nog registreertDeze browser wordt niet meer ondersteund.
Upgrade naar Microsoft Edge om te profiteren van de nieuwste functies, beveiligingsupdates en technische ondersteuning.
Applies to:
SQL Server
This article is relevant only for backup and restore of SQL Server databases that are using the full or bulk-logged recovery models.
A tail-log backup captures any log records that haven't yet been backed up (the tail of the log), to prevent work loss and to keep the log chain intact. Before you can recover a SQL Server database to its latest point in time, you must back up the tail of its transaction log. The tail-log backup is the last backup of interest in the recovery plan for the database.
Not all restore scenarios require a tail-log backup. You don't need a tail-log backup if the recovery point is contained in an earlier log backup. A tail-log backup is unnecessary if you're moving or replacing (overwriting) a database, and don't need to restore it to a point of time after its most recent backup.
We recommend that you take a tail-log backup in the following scenarios:
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, use the WITH NO_TRUNCATE
option. NO_TRUNCATE
is effectively the same as a copy-only transaction log backup. Using WITH NORECOVERY
is optional, because no transactions can occur at this time.
If a database is damaged, try to take a tail-log backup by using the WITH CONTINUE_AFTER_ERROR
option of the BACKUP
statement.
On a damaged database, backing up the tail of the log can succeed only if the log files are undamaged, the database is in a state that supports tail-log backups, and the database doesn't contain any bulk-logged changes. If a tail-log backup can't be created, any transactions committed after the latest log backup are lost.
The following table summarizes the NORECOVERY
, NO_TRUNCATE
, and CONTINUE_AFTER_ERROR
options for BACKUP
.
BACKUP LOG option | Comments |
---|---|
NORECOVERY |
Use NORECOVERY whenever you intend to continue with a restore operation on the database. NORECOVERY takes the database into the restoring state. This step guarantees that the database doesn't change after the tail-log backup. The log is truncated unless the NO_TRUNCATE option or COPY_ONLY option is also specified.Important: Avoid using NO_TRUNCATE , except when the database is damaged or offline. You may need to put the database into single-user mode to obtain exclusive access before performing the restore with NORECOVERY . After the restore, set the database back to multi-user mode. |
CONTINUE_AFTER_ERROR |
Use CONTINUE_AFTER_ERROR only if you're backing up the tail of a damaged database.When you back up the tail of the log of a damaged database, some of the metadata ordinarily captured in log backups might be unavailable. For more information, see the next section. |
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
.
If the metadata in a tail-log backup is incomplete, the backupfilegroup table is missing most of the information about filegroups at the time of the tail-log backup. Most of the backupfilegroup
table columns are NULL
; the only meaningful columns are as follows:
backup_set_id
filegroup_id
type
type_desc
is_readonly
To create a tail-log backup, see Back Up the Transaction Log When the Database Is Damaged (SQL Server).
To restore a transaction log backup, see Restore a Transaction Log Backup (SQL Server).
gebeurtenis
31 mrt, 23 - 2 apr, 23
De grootste SQL-, Fabric- en Power BI-leerevenement. 31 maart – 2 april. Gebruik code FABINSIDER om $ 400 te besparen.
Zorg dat u zich vandaag nog registreertTraining
Documentatie
Een back-up van een transactielogboek herstellen (SQL Server) - SQL Server
In dit artikel wordt beschreven hoe u een back-up van een transactielogboek in SQL Server herstelt met behulp van SQL Server Management Studio of Transact-SQL.
Een SQL Server-database herstellen naar een bepaald tijdstip (volledig herstelmodel) - SQL Server
Een SQL Server-database herstellen naar een bepaald tijdstip (volledig herstelmodel)
Overzicht van herstel en terugwinning (SQL Server) - SQL Server
Leer meer over de processen die betrokken zijn bij het herstellen van een SQL Server-database na een fout door een reeks back-ups van SQL Server in de juiste volgorde te herstellen.