Transaction Log Backup includes all log records that were not backed up in a previous log backup.
Transaction Log Backup
- It will backup transaction log only.
- Its backed up from the last successful full backup, differential backup, or log backups
- Transaction logs are backed up for two reasons: (to ensure log is truncated periodically and to reduce amount of possible data loss in case of disk failure )
- Transaction logs can be backed up as part of full/transaction log backup strategy, or as parto f full/differential/transaction backup strategy.
- Transaction logs can be backed up when recovery model is et to full or bulk logged.
- Transaction log backups are not available for simple recovery model.
- The basic syntax to perform a transaction log backup follows. It will fail if a full backup doesn’t exist.
- Simple recovery mode causes the transaction log to be truncated prior to backup
--First need to change the recovery model from simple to full ALTER DATABASE [AdventureWorks] SET RECOVERY FULL WITH NO_WAIT -- A Full database backup must be taken after the recovery mode -- has been changed in order set a base for future tlog backups. --The Following full backup utilizes two devices on the same drive. BACKUP DATABASE [AdventureWorks] TO DISK = N’C:\backup\AdventureWorks_Full_Dev1.bak’, DISK = N’C:\backup\AdventureWorks_Full_Dev2.bak’ WITH NOFORMAT, NOINIT, SKIP, NOREWIND, NOUNLOAD, STATS = 10 --Transaction log backups can be taken now that a base has been established --The following tlog backup is written to a single file BACKUP LOG [AdventureWorks] TO DISK = N’C:\backup\log\AdventureWorks_FirstAfterFull.trn’ WITH NOFORMAT, INIT, NAME = N’AdventureWorks-Transaction Log Backup’, SKIP, NOREWIND, NOUNLOAD, STATS = 10, CHECKSUM
NO_TRUNCATE Options
- You can use NO_TRUNCATE option when the log is available but database is not.
- Its function opposite to NO_LOG and TRUNCATE_ONLY.
- You can BACKUP LOG with NO_TRUNCATE option, log is backed up but checkpoint is not run.
- Tthis new log backup can restore as well, enableing recovery to time of failure.
- Only transaction lost rare those were not yet commited
NORECOVERY | STAND = undo_file_name Options
- NoRecovery option cause tail of the log to be backup up and leave database in restoring state
- The tail of the log is active portion of the log that contains transactions that have not yet been backup up.
- Typically, NoRecovery option is used with NO_TRUNCATE option to retain contents of the log.
- STANDBY option also backs up tail of log, but it leaves the database in readonly/standby state.
- The read-only state allows inquery on the database and allow additional transaction logs to be applied to database as well.
- STANDBY option proces same results as executing BACKUP LOG WITH NORECOVERY followed by a RESTORE WITH STANDBY
WITH [NO_TRUNCATE], NORECOVERY | STANDBY=undo_file_name OR WITH NO_LOG | TRUNCATE_ONLY
NO_LOG | TRUNCATE_ONLY
- NO_LOG | TRUNCATE_ONLY options are synonymous.
- They cause inactive portion of transaction log to be discarded ( be carefull in useing it )
- These options are n o more in future SQL Server
Tags: Transaction Log Backup