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


Page Restore


Page Restore

Author
Message
NickDBA
NickDBA
SSC-Addicted
SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)

Group: General Forum Members
Points: 471 Visits: 938
Hi experts, whats the best / easiest way for me to actually corrupt a page in my database (on local test machine) in order for me to then identify it using CHECKDB and practice a page restore scenario?

Thanks
GilaMonster
GilaMonster
SSC Guru
SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)

Group: General Forum Members
Points: 86977 Visits: 45267
Hex editor works.

Pick a page you want to corrupt, identify an allocated page using DBCC IND for a table and cacluate the offset as (page Number)*8192 bytes
Take the DB offline, open the data file in a hex editor (HxD is good), go to the offset calculated, write garbage over a few bytes, save, exit
Bring the DB back online.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


John Mitchell-245523
John Mitchell-245523
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14077 Visits: 15950
Tony Rogerson also covers this in detail in his blog.

John
NickDBA
NickDBA
SSC-Addicted
SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)

Group: General Forum Members
Points: 471 Visits: 938
Thanks guys...two different approaches. I'll try and have a go at each and post back my success rate.

Again, thanks :-)
NickDBA
NickDBA
SSC-Addicted
SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)

Group: General Forum Members
Points: 471 Visits: 938
Gail that worked a charm. I followed the steps you outlined:

Identify Page (using DBCC IND)
Took DB offline
Opened MDF in HxD and navigated to page(offset)
Added some garbage text and save
Brought the DB back online and ran DBCC CHECKDB (this clearly reported an issue)

Steps to remedy:

Back up tail of the log
restore DB page (the one I trashed) with norecovery
restore all logs and the final tail backup

DBCC CHECKDB reports no issue and the table contains the data I expected.


That was great exercise to run on my test DB and feel it's added a little something to my skillset!! I'll play about with different options (repair_allow_data_loss) etc just to see what happens.

Again, thanks Gail
GilaMonster
GilaMonster
SSC Guru
SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)

Group: General Forum Members
Points: 86977 Visits: 45267
Excellent!

<Shameless self-promotion> There's a chapter on page restores in SQL Server MVP Deep Dives 2 </Shameless self-promotion>

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


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