You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/relational-databases/backup-restore/apply-transaction-log-backups-sql-server.md
+10-9Lines changed: 10 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "Apply Transaction Log Backups (SQL Server) | Microsoft Docs"
3
3
ms.custom: ""
4
-
ms.date: "08/14/2016"
4
+
ms.date: "10/23/2019"
5
5
ms.prod: sql
6
6
ms.prod_service: backup-restore
7
7
ms.reviewer: ""
@@ -23,7 +23,6 @@ ms.author: mathoma
23
23
24
24
This topic describes applying transaction log backups as part of restoring a [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] database.
25
25
26
-
27
26
## <aname="Requirements"></a> Requirements for restoring transaction log backups
28
27
To apply a transaction log backup, the following requirements must be met:
29
28
@@ -33,14 +32,16 @@ ms.author: mathoma
33
32
34
33
-**Database not yet recovered:** The database cannot be recovered until after the final transaction log has been applied. If you recover the database after restoring one of the intermediate transaction log backups, that before the end of the log chain, you cannot restore the database past that point without restarting the complete restore sequence, starting with the full database backup.
35
34
36
-
> **TIP!** A best practice is to restore all the log backups (RESTORE LOG *database_name* WITH NORECOVERY). Then, after restoring the last log backup, recover the database in a separate operation (RESTORE DATABASE *database_name* WITH RECOVERY).
35
+
> [!TIP]
36
+
> A best practice is to restore all the log backups (`RESTORE LOG *database_name* WITH NORECOVERY`). Then, after restoring the last log backup, recover the database in a separate operation (`RESTORE DATABASE *database_name* WITH RECOVERY`).
37
37
38
38
## <aname="RecoveryAndTlogs"></a> Recovery and transaction logs
39
-
When you finish the restore operation and recover the database, recovery rolls back all incomplete transactions. This is known as the *undo phase*. Rolling back is required to restore the integrity of the database. After rollback, the database goes online, and no more transaction log backups can be applied to the database.
40
-
41
-
For example, a series of transaction log backups contain a long-running transaction. The start of the transaction is recorded in the first transaction log backup, but the end of the transaction is recorded in the second transaction log backup. There is no record of a commit or rollback operation in the first transaction log backup. If a recovery operation runs when the first transaction log backup is applied, the long-running transaction is treated as incomplete, and data modifications recorded in the first transaction log backup for the transaction are rolled back. [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] does not allow for the second transaction log backup to be applied after this point.
39
+
When you finish the restore operation and recover the database, the recovery process is executed to ensure the integrity of the database. For more information about the recovery process, see [Restore and Recovery Overview (SQL Server)](../../relational-databases/backup-restore/restore-and-recovery-overview-sql-server.md#TlogAndRecovery).
40
+
41
+
After the recovery process completes, the database goes online, and no more transaction log backups can be applied to the database. For example, a series of transaction log backups contain a long-running transaction. The start of the transaction is recorded in the first transaction log backup, but the end of the transaction is recorded in the second transaction log backup. There is no record of a commit or rollback operation in the first transaction log backup. If a recovery operation runs when the first transaction log backup is applied, the long-running transaction is treated as incomplete, and data modifications recorded in the first transaction log backup for the transaction are rolled back. [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] does not allow for the second transaction log backup to be applied after this point.
42
42
43
-
> **NOTE:** In some circumstances, you can explicitly add a file during log restore.
43
+
> [!NOTE]
44
+
> In some circumstances, you can explicitly add a file during log restore.
44
45
45
46
## <aname="PITrestore"></a> Use log backups to restore to the failure point
46
47
Assume the following sequence of events.
@@ -98,6 +99,6 @@ ms.author: mathoma
98
99
-[Recover a Database Without Restoring Data (Transact-SQL)](../../relational-databases/backup-restore/recover-a-database-without-restoring-data-transact-sql.md)
[SQL Server Transaction Log Architecture and Management Guide](../../relational-databases/sql-server-transaction-log-architecture-and-management-guide.md)
Copy file name to clipboardExpand all lines: docs/relational-databases/backup-restore/piecemeal-restores-sql-server.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "Piecemeal Restores (SQL Server) | Microsoft Docs"
3
3
ms.custom: ""
4
-
ms.date: "03/14/2017"
4
+
ms.date: "10/23/2019"
5
5
ms.prod: sql
6
6
ms.prod_service: backup-restore
7
7
ms.reviewer: ""
@@ -138,7 +138,7 @@ ms.author: mathoma
138
138
In the Enterprise edition, any offline secondary filegroup can be restored and recovered while the database remains online. If a specific read-only file is undamaged and consistent with the database, the file does not have to be restored. For more information, see [Recover a Database Without Restoring Data (Transact-SQL)](../../relational-databases/backup-restore/recover-a-database-without-restoring-data-transact-sql.md).
139
139
140
140
### Applying Log Backups
141
-
If a read-only filegroup has been read-only since before the file backup was created, applying log backups to the filegroup is unnecessary and is skipped by file restore. If the filegroup is read/write, an unbroken chain of log backups must be applied to the last full or differential restore to bring the filegroup forward to the current log file.
141
+
If a read-only filegroup has been read-only since before the file backup was created, applying log backups to the filegroup is unnecessary and is skipped by file restore. If the filegroup is read/write, an unbroken chain of log backups must be applied to the last full or differential restore to bring the filegroup forward to the current log file. For more information about the recovery process, see [Restore and Recovery Overview (SQL Server)](../../relational-databases/backup-restore/restore-and-recovery-overview-sql-server.md#TlogAndRecovery).
[Restore a SQL Server Database to a Point in Time (Full Recovery Model)](../../relational-databases/backup-restore/restore-a-sql-server-database-to-a-point-in-time-full-recovery-model.md)
174
174
[Restore and Recovery Overview (SQL Server)](../../relational-databases/backup-restore/restore-and-recovery-overview-sql-server.md)
175
-
[Plan and Perform Restore Sequences (Full Recovery Model)](../../relational-databases/backup-restore/plan-and-perform-restore-sequences-full-recovery-model.md)
176
-
175
+
[Plan and Perform Restore Sequences (Full Recovery Model)](../../relational-databases/backup-restore/plan-and-perform-restore-sequences-full-recovery-model.md)
176
+
[Restore and Recovery Overview (SQL Server)](../../relational-databases/backup-restore/restore-and-recovery-overview-sql-server.md)
Copy file name to clipboardExpand all lines: docs/relational-databases/backup-restore/recover-a-database-without-restoring-data-transact-sql.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "Recover a Database Without Restoring Data (Transact-SQL) | Microsoft Docs"
3
3
ms.custom: ""
4
-
ms.date: "03/14/2017"
4
+
ms.date: "10/23/2019"
5
5
ms.prod: sql
6
6
ms.prod_service: backup-restore
7
7
ms.reviewer: ""
@@ -34,16 +34,16 @@ ms.author: mathoma
34
34
35
35
The [RESTORE](../../t-sql/statements/restore-statements-transact-sql.md) syntax for a recovery-only database restore is as follows:
36
36
37
-
RESTORE DATABASE *database_name* WITH RECOVERY
37
+
`RESTORE DATABASE *database_name* WITH RECOVERY`
38
38
39
39
> [!NOTE]
40
-
> The FROM **=**\<*backup_device>* clause is not used for recovery-only restores because no backup is necessary.
40
+
> The FROM **=**\<*backup_device>* clause is not used for recovery-only restores because no backup is necessary.
41
41
42
42
**Example**
43
43
44
44
The following example recovers the [!INCLUDE[ssSampleDBobject](../../includes/sssampledbobject-md.md)] sample database in a restore operation without restoring data.
A database is restored piecemeal. After restore of the primary filegroup is complete, one or more of the unrestored files are consistent with the new database state, perhaps because it has been read-only for some time. These files only have to be recovered; data copying is unnecessary.
56
56
57
-
A recovery-only restore operation brings the data in the offline filegroup online; no data-copy, redo, or undo phase occurs. For information about the phases of restore, see [Restore and Recovery Overview (SQL Server)](../../relational-databases/backup-restore/restore-and-recovery-overview-sql-server.md).
57
+
A recovery-only restore operation brings the data in the offline filegroup online; no data-copy, redo, or undo phase occurs. For information about the phases of restore, see [Restore and Recovery Overview (SQL Server)](../../relational-databases/backup-restore/restore-and-recovery-overview-sql-server.md#TlogAndRecovery).
58
58
59
59
The [RESTORE](../../t-sql/statements/restore-statements-transact-sql.md) syntax for a recovery-only file restore is:
The following example illustrates a recovery-only file restore of the files in a secondary filegroup, `SalesGroup2`, in the `Sales` database. The primary filegroup has already been restored as the initial step of a piecemeal restore, and `SalesGroup2` is consistent with the restored primary filegroup. Recovering this filegroup and bringing it online requires only a single statement.
66
66
67
-
```
67
+
```sql
68
68
RESTORE DATABASE Sales FILEGROUP=SalesGroup2 WITH RECOVERY;
69
69
```
70
70
71
-
## Examples of Completing a Piecemeal Restore Scenario with a Recovery-Only Restore
71
+
## Examples of completing a piecemeal restore scenario with a recovery-only restore
72
72
**Simple recovery model**
73
73
74
74
-[Example: Piecemeal Restore of Database (Simple Recovery Model)](../../relational-databases/backup-restore/example-piecemeal-restore-of-database-simple-recovery-model.md)
@@ -89,5 +89,5 @@ RESTORE DATABASE Sales FILEGROUP=SalesGroup2 WITH RECOVERY;
Copy file name to clipboardExpand all lines: docs/relational-databases/backup-restore/recover-to-a-log-sequence-number-sql-server.md
+12-16Lines changed: 12 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "Recover to a Log Sequence Number (SQL Server) | Microsoft Docs"
3
3
ms.custom: ""
4
-
ms.date: "03/17/2017"
4
+
ms.date: "10/23/2019"
5
5
ms.prod: sql
6
6
ms.prod_service: backup-restore
7
7
ms.reviewer: ""
@@ -29,17 +29,12 @@ ms.author: mikeray
29
29
You can use a log sequence number (LSN) to define the recovery point for a restore operation. However, this is a specialized feature that is intended for tools vendors and is unlikely to be generally useful.
30
30
31
31
## <aname="LSNs"></a> Overview of Log Sequence Numbers
32
-
LSNs are used internally during a RESTORE sequence to track the point in time to which data has been restored. When a backup is restored, the data is restored to the LSN corresponding to the point in time at which the backup was taken. Differential and log backups advance the restored database to a later time, which corresponds to a higher LSN.
33
-
34
-
Every record in the transaction log is uniquely identified by a log sequence number (LSN). LSNs are ordered such that if LSN2 is greater than LSN1, the change described by the log record referred to by LSN2 occurred after the change described by the log record LSN.
35
-
36
-
The LSN of a log record at which a significant event occurred can be useful for constructing correct restore sequences. Because LSNs are ordered, they can be compared for equality and inequality (that is, **\<**, **>**, **=**, **\<=**, **>=**). Such comparisons are useful when constructing restore sequences.
32
+
LSNs are used internally during a RESTORE sequence to track the point in time to which data has been restored. When a backup is restored, the data is restored to the LSN corresponding to the point in time at which the backup was taken. Differential and log backups advance the restored database to a later time, which corresponds to a higher LSN. For more information about LSNs, see the [SQL Server Transaction Log Architecture and Management Guide](../../relational-databases/sql-server-transaction-log-architecture-and-management-guide.md#Logical_Arch).
37
33
38
34
> [!NOTE]
39
-
> LSNs are values of data type **numeric**(25,0). Arithmetic operations (for example, addition or subtraction) are not meaningful and must not be used with LSNs.
40
-
41
-
42
-
## Viewing LSNs Used by Backup and Restore
35
+
> LSNs are values of data type **numeric(25,0)**. Arithmetic operations (for example, addition or subtraction) are not meaningful and must not be used with LSNs.
36
+
37
+
## Viewing LSNs used by Backup and Restore
43
38
The LSN of a log record at which a given backup and restore event occurred is viewable using one or more of the following:
> LSNs also appear in some messages in the error log.
57
52
58
-
## Transact-SQL Syntax for Restoring to an LSN
53
+
## Transact-SQL Syntax for restoring to an LSN
59
54
By using a [RESTORE](../../t-sql/statements/restore-statements-transact-sql.md) statement, you can stop at or immediately before the LSN, as follows:
60
55
61
56
- Use the WITH STOPATMARK **='**lsn:_<lsn_number>_**'** clause, where lsn:*\<lsnNumber>* is a string that specifies that the log record that contains the specified LSN is the recovery point.
@@ -71,7 +66,7 @@ ms.author: mikeray
71
66
## Examples
72
67
The following example assumes that the `AdventureWorks` database has been changed to use the full recovery model.
73
68
74
-
```
69
+
```sql
75
70
RESTORE LOG AdventureWorks FROM DISK ='c:\adventureworks_log.bak'
[Restore and Recovery Overview (SQL Server)](../../relational-databases/backup-restore/restore-and-recovery-overview-sql-server.md#TlogAndRecovery)
94
+
[SQL Server Transaction Log Architecture and Management Guide](../../relational-databases/sql-server-transaction-log-architecture-and-management-guide.md)
0 commit comments