SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Full backup Scenario


Full backup Scenario

Author
Message
suja.jamesgeorge
suja.jamesgeorge
SSC Rookie
SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)

Group: General Forum Members
Points: 41 Visits: 54
Comments posted to this topic are about the item Full backup Scenario
Oleg Netchaev
Oleg Netchaev
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1777 Visits: 1814
This is a very good question, which definitely required some thinking to answer. Thank you.

It looks like I am the first one who answered this one correctly :-). The full backup is designed to restore the database to the state in which it was at the moment the backup has finished, so the answer makes perfect sense.

Oleg
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
SSCrazy Eights
SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)

Group: General Forum Members
Points: 8887 Visits: 7281
Tricky.
good question

____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Hugo Kornelis
Hugo Kornelis
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10994 Visits: 11990
Great question!

One additional comment that was missing from the question and description, is how pending transactions are handled.

IF the session inserting the 10000 rows does so within a transaction, and the transaction is not yet committed when the backup finishes, then a restore from this backup will contain none of those rows.
IF the session inserting the 10000 rows does not use an explicit transaction (making each individual insert statement an implied transaction of its own), then a restore from this backup will contain all the rows that were inserted before the backup finished, and none of the rows inserted after the backup finished.

Even though the portion of the transaction log that is added to the backup will include modifications by uncommitted transactions, the restore process will not restore those changes (or even undo them if they were already made in the data page when it was copied) because the transaction is still uncommitted at the end of the backup.


Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Ali Asghar Sharifi
Ali Asghar Sharifi
SSC Veteran
SSC Veteran (292 reputation)SSC Veteran (292 reputation)SSC Veteran (292 reputation)SSC Veteran (292 reputation)SSC Veteran (292 reputation)SSC Veteran (292 reputation)SSC Veteran (292 reputation)SSC Veteran (292 reputation)

Group: General Forum Members
Points: 292 Visits: 53
Thank you for your question.It's a good point that I had never attended.It's obvious in question that 10000 rows are inserted without transaction because the records are inserting through a loop and any records that insert until the completion time of full backup will be included.
vogelz
vogelz
Grasshopper
Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)

Group: General Forum Members
Points: 13 Visits: 39
I'm not sure I understand the explanation though:
Whenever a full backup is initiated it will place a pointer in the transaction log in order to understand from where the backup started. So any transaction happening,after the pointer, will be included in the backup.


Is this saying that a full backup backs up everything fully before the pointer, and then pulls the data after the pointer? Otherwise, what is the point of the pointer?

If it doesn't mean that, what does it mean? Why would a pointer be placed in the transaction log on the initiation of a full backup if it is going to backup the data before AND after the pointer?
Hugo Kornelis
Hugo Kornelis
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10994 Visits: 11990
vogelz (3/16/2010)
I'm not sure I understand the explanation though:
Whenever a full backup is initiated it will place a pointer in the transaction log in order to understand from where the backup started. So any transaction happening,after the pointer, will be included in the backup.


Is this saying that a full backup backs up everything fully before the pointer, and then pulls the data after the pointer? Otherwise, what is the point of the pointer?

If it doesn't mean that, what does it mean? Why would a pointer be placed in the transaction log on the initiation of a full backup if it is going to backup the data before AND after the pointer?

I'm not sure if the explanation is 100% technically accurate. My understanding (which might be wrong as well) is that the backup first copies all the data pages, then adds all the log pages starting from the start of the oldest uncommitted transaction right up until the time the backup ends.

On a restore, first all data pages are restored; then the log entries included in the backup are used to
a) roll forward any transactions that were committed while the backup was running, and
b) roll back any changes from transactions that were not yet commited when the backup finished.
The latter is required because the backed up data pages may already have been modified by those transactions.

As I said, the exact implementation might be slightly different. But the main point to remember is that the backup/restore process ensures that the restored database includes the changes from all the transactions that were finished when the backup ended, and no changes at all from any transactions that were still running at that time.


Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
vogelz
vogelz
Grasshopper
Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)

Group: General Forum Members
Points: 13 Visits: 39
Thanks Hugo, that does make much more sense.

Andrew
sjimmo
sjimmo
Hall of Fame
Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)

Group: General Forum Members
Points: 3748 Visits: 2904
Hugo, after getting the questin wrong;-) and re-reading a few times in disbelief I found on <http://msdn.microsoft.com/en-us/library/ms175477.aspx> - Each data backup includes part of the transaction log so that the backup can be recovered to the end of that backup.

So, in a full backup, all completed transactions will be added to the full dump. everything else will be added to the transaction log dumps if being performed.

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
Cliff Jones
Cliff Jones
SSCarpal Tunnel
SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)

Group: General Forum Members
Points: 4279 Visits: 3648
This was a good question. And thanks Hugo for the explanation.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search