Transaction Log Backups

  • Comments posted to this topic are about the item Transaction Log Backups

    Paul Randal
    CEO, SQLskills.com: Check out SQLskills online training!
    Blog:www.SQLskills.com/blogs/paul Twitter: @PaulRandal
    SQL MVP, Microsoft RD, Contributing Editor of TechNet Magazine
    Author of DBCC CHECKDB/repair (and other Storage Engine) code of SQL Server 2005

  • sad, i got this one wrong... 🙁

    2 options looked very likely ...

    http://msdn.microsoft.com/en-us/library/aa173551(SQL.80).aspx

  • Thanks Paul. Excellent question.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • from sql help http://msdn.microsoft.com/en-us/library/ms186865.aspx

    Under the full recovery model or bulk-logged recovery model, conventional backups also include sequential transaction log backups (or log backups), which are required. Each log backup covers the portion of the transaction log that was active when the backup was created, and it includes all log records not backed up in a previous log backup.

    This indecates that the last answer is correct.

    Also it would need to backup anything not backed up in a previous log backup so that it could restore to a point in time after the last log backup.

  • Good question..simple one if basics are clear...

  • This was removed by the editor as SPAM

  • This page suggests that option 2 is correct:

    http://msdn.microsoft.com/en-us/library/ms186289.aspx

    You can re-create a whole database in one step by restoring the database from a full database backup to any location. Enough of the transaction log is included in the backup to let you recover the database to the time when the backup finished.

  • Great question - got it wrong, but caused me to think.

    Steve Jimmo
    Sr DBA
    “If we ever forget that we are One Nation Under God, then we will be a Nation gone under." - Ronald Reagan

  • Good question. Easy if you understand recovery models and backup/restore processes.

  • @jadsmith But the question wasn't about log backups - it was about full backups. Full backups do not affect log backups, nor do they take them into account. A full backup only has to include the transaction log necessary to recover the database consistently to the time when the data-reading portion of the backup completed. It doesn't matter if the transaction log is GBs and there hasn't been a log backup for weeks - the full backup doesn't backup log it doesn't need.

    Only a log backup will backup all log generated since the last log backup completes. And only a log backup in the FULL or BULK_LOGGED recovery models will allow the log to clear/truncate.

    @John.curran.z3g That wouldn't be enough to recover the database. If there was a long running transaction that started before the full backup did, only backing up the transaction log generated during the backup would not allow the transaction to be rolled back correctly during the restore operation. All the transaction log for that transaction, all the way back to the initial LOP_BEGIN_XACT log record must be backed up for recovery to be able to operate correctly.

    See my article in TechNet Magazine for a more full explanation: Understanding SQL Server Backups and also this blog post which gives you code examples you can use to convince yourself of what's going on under the covers: Misconceptions around the log and log backups: how to convince yourself

    Thanks

    Paul Randal
    CEO, SQLskills.com: Check out SQLskills online training!
    Blog:www.SQLskills.com/blogs/paul Twitter: @PaulRandal
    SQL MVP, Microsoft RD, Contributing Editor of TechNet Magazine
    Author of DBCC CHECKDB/repair (and other Storage Engine) code of SQL Server 2005

  • Lynn Pettis (2/9/2010)


    Good question. Easy if you understand recovery models and backup/restore processes.

    Yeah. What he said. Full means complete, all in one.

    Nice question.

    Tom Garth
    Vertical Solutions[/url]

    "There are three kinds of men. The one that learns by reading. The few who learn by observation. The rest of them have to pee on the electric fence for themselves." -- Will Rogers
  • Excellent question. Then I noticed who the author of it is, and realized... but of course!

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • That wouldn't be enough to recover the database. If there was a long running transaction that started before the full backup did, only backing up the transaction log generated during the backup would not allow the transaction to be rolled back correctly during the restore operation

    I was under the impression that at the start of a backup, a checkpoint is issued and a marker is placed in the trans log indicating that a database wide lock was obtained (to ensure there are no running transactions), this lock is then released and the backup is performed. At the end of the backup, another checkpoint is issued (another lock obtained and released) and the section of the transaction log between the two checkpoints is backed up. Has this changed between 2005 and 2008 or did I dream all that 😀

  • With all due respect Ted, you dreamed everything you described above 🙂 It doesn't do any of that except the checkpoint at the start, and that's just to flush out as many dirty pages from the buffer pool as it can, so as to reduce the amount of REDO recovery to do during the restore sequence.

    [Edit: btw, a checkpoint doesn't take locks either - see my blog post for details: How do checkpoints work and what gets logged. Whatever differing descriptions you may read elsewhere are unfortunately incorrect - this description is based on the code itself.]

    Take a look at my backup article I referenced a few posts above which explains exactly what happens.

    It's worked the same way since 7.0 up to 2008.

    Thanks

    Paul Randal
    CEO, SQLskills.com: Check out SQLskills online training!
    Blog:www.SQLskills.com/blogs/paul Twitter: @PaulRandal
    SQL MVP, Microsoft RD, Contributing Editor of TechNet Magazine
    Author of DBCC CHECKDB/repair (and other Storage Engine) code of SQL Server 2005

  • @paul-2,

    Great question as expected from you.

    thanks.

Viewing 15 posts - 1 through 15 (of 17 total)

You must be logged in to reply to this topic. Login to reply