Back Up a Transaction Log (Transact-SQL)

[本文件僅供預覽,在未來的版本中可能有所變更。空白的主題則以預留位置表示。]

This topic explains how to create a transaction log backup using a BACKUP LOG statement.

To create a transaction log backup

  1. Execute the BACKUP LOG statement to back up the transaction log, specifying the following:

    • The name of the database to which the transaction log that you want to back up belongs.

    • The backup device where the transaction log backup is written.

  2. Optionally, specify:

    • The INIT clause to overwrite the backup media, and write the backup as the first file on the backup media. If no existing media header exists, one is automatically written.

    • The SKIP and INIT clauses to overwrite the backup media even if there are either backups on the backup media that have not yet expired, or the media name does not match the name on the backup media.

    • The FORMAT clause, when you are using media for the first time, to initialize the backup media and rewrite any existing media header.

      The INIT clause is not required if the FORMAT clause is specified.

      重要事項重要事項

      Use extreme caution when you are using the FORMAT or INIT clauses of the BACKUP statement as this destroys any backups previously stored on the backup media.

範例

重要事項重要事項

The MyAdvWorks_FullRM database is a copy of AdventureWorks, which uses the simple recovery model. To permit log backups, before taking a full database backup, the database was set to use the full recovery model by using: ALTER DATABASE MyAdvWorks_FullRM SET RECOVERY FULL.

This example creates a transaction log backup for the MyAdvWorks_FullRM database to the previously created named backup device, MyAdvWorks_FullRM_log1.

BACKUP LOG MyAdvWorks_FullRM
   TO MyAdvWorks_FullRM_log1
GO

請參閱

工作

Back Up a Transaction Log (SQL Server Management Studio)

還原交易記錄備份 (Transact-SQL)

參考

BACKUP (Transact-SQL)

概念

寫滿交易記錄疑難排解 (SQL Server 錯誤 9002)

Optimizing Backup and Restore Performance in SQL Server

將資料庫還原到備份中的時間點 (完整復原模式)

教學課程

完整檔案備份

使用交易記錄備份 (完整復原模式)