Re: Still don't understand log backups

From: AnthonyThomas (Anthony.Thomas_at_CommerceBank.com)
Date: 01/11/05


Date: Mon, 10 Jan 2005 23:01:17 -0600

I realize this is an old post...but I'm just starting to catch up.

However, I found this post interesting.

Sometimes, it can be difficult the level of a poster's understanding when
inquiring to processes. In some respects, the poster can be quite
knowlegeable, in others, there seems to be some missing information.

So, making no assumptions, I did notice that one important component
concerning transaction logs and there makeup had been overlooked.

The transaction log, whether or not it is one or many files, is a serial,
circular sequence of many "virtual" files, or partitioned sections, of the
entire transaction log itself. As transactions to the database begin, LSN,
or Logical Sequence Numbers, are issued for each transaction and each begins
within a different "virtual" log. Until these transactions commit, these
"virtual" logs are kept "active" and can not be overwritten by other
transactions.

Each transaction begins with the next available "virtual" log, in round
robin fashion, until the end of the physical log file is reached. If there
are multiple log files, the begining "virtual" log of the next file is
initiated, until all physical logs have been consumed.

Now, as transactions commit, they are marked, and when a transaction log
backup is executed, the active "virtual" logs are backed up, but the
committed ones are backed up and then marked as reusable. Reusable
"virtual" logs are not backed up because it is assumed already backed up.
When all transaction log files have reached their respective last "virtual"
log segments, the transaction log wraps around and begins the next
transaction in the first available "virtual" segment available, that is,
marked as reusable, in the first physical file. If no "virtual" logs are
available, the physical files will be grown if set to AUTOGROW and error out
if not.

The Audit trail you seek, is in the transaction log backups, not the live
file(s). You can archive these backups and keep the entire database
lifetime, starting with the first FULL DATABASE backup, and every
transaction log backup since.

Hope this helps.

Sincerely,

Anthony Thomas

-- 
"Maury Markowitz" <MauryMarkowitz@discussions.microsoft.com> wrote in
message news:7E2933D7-51C1-4551-A676-CB931F8C3C05@microsoft.com...
The background: I'd like to scrape my log files for changes made to a
particular table. This seemed to offer the best daytime performance (ie, no
hit at all) for a fairly low (~2-3 mins) nightly processing run. The server
is set up to do a full backup weekly, and a log backup nightly, using BULK
LOGGED.
I'm looking at the resulting data now, and I am very confused as to what is
going on. As I understand it the online log is supposed to contain every
change ever made, and the log backups should be a backup of that file -- 
thus
containing every change ever made. However if what I think I'm seeing is
true, something in that statement is not correct.
My questions:
1) Using BULK LOGGED (or FULL), does the online log file contain EVERY
transaction for all time -- given that I don't truncate it manually?
2) When the log is backed up, what EXACTLY is backed up? Everything in the
log file? Or only things that happened since the last backup?
3) Does the full backup have any effect whatsoever on (1) or (2)?
Differential backups?
4) Does issuing a CHECKPOINT -- which the dox seem to suggest happens
periodically when doing backups and such -- have any effect on (1) or (2)?
The questions involve keeping the audit trail of the system. When I examine
the scrapes of my log backups, they seem to have new changes only. This is
not what I expected, I thought the backup would be a full backup of the log
file (along with the markers needed for BULK LOGGED) every time. But if my
scraping is correct, then this is not the case, it's only the diffs since
the
last backup.
Can someone clear this up? I'm confusing myself.


Relevant Pages

  • Re: Log Shipping: question about secondary dB mode?
    ... Regular transaction log backups will allow the committed and backed up portion of the log file to be reused for new transactions. ... And last to recover the db you restore the last log file using the WITH RECOVERY option and you should be all set. ... all the backup and restore jobs are proceeding without errors. ...
    (microsoft.public.sqlserver.tools)
  • Re: SQL 2005 Shrink issue
    ... When you perform a Transaction Log Backup, passive virtual logs in your transaction log file are deleted. ... you can change your database's recovery model to SIMPLE when you want to get rid of your passive virtual logs in your transaction log file. ...
    (microsoft.public.sqlserver.tools)
  • Re: Restore Database w/Large Transaction Log File
    ... If I am reading you correctly, the backup has already been trasmitted to the ... AGAIN, just like the other respondents have told you: shrink the log file, ... Shrinking a database transaction log file that has that has been pre-gone to 200 GB in size, will not save any disk space on the restore. ...
    (microsoft.public.sqlserver.server)
  • Re: suitable plan for Log backup
    ... After the transaction log backup, I have tried to perform the shrinkfile command but I got the error message as below: ... How can I reduce the log file size in this situation? ...
    (microsoft.public.sqlserver.server)
  • Re: Very large LDF
    ... If a database is backed up using the 'Complete Backup' option via ... You will have to backup the transaction log seperately. ... Check the Recovery model you are using for that database. ...
    (microsoft.public.sqlserver.security)