Page Restore

  • 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

  • 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
  • Tony Rogerson also covers this in detail in his blog.

    John

  • Thanks guys...two different approaches. I'll try and have a go at each and post back my success rate.

    Again, thanks 🙂

  • 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

  • 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

Viewing 6 posts - 1 through 5 (of 5 total)

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