Warner Chaves MCM / MVP / SQLTurbo.com / Pythian.com The Restore Cookbook SQLSaturday Ottawa 2015 Warner Chaves MCM / MVP / SQLTurbo.com / Pythian.com
Bio SQL Server DBA for 10 years. Previously an L3 DBA at HP, now a Principal Consultant at Pythian in Ottawa Ontario. SQL Server MCM and MVP. Twitter: @warchav Email: warner@sqlturbo.com Blog: sqlturbo.com Company: Pythian.com
Agenda Objective: present different RESTORE scenarios in the form of recipes: easy to remember, to reference and repeat. Scenarios we’ll visit: RESTORE of a damaged FILEGROUP. RESTORE of a specific damaged FILE. RESTORE of a damaged PAGE. Recover from losing the Transaction Log.
RESTORE a damaged FILEGROUP Ingredients: Database in FULL recovery mode. Full backup or individual Filegroup backups (preferable). Log backups. Sequence: Take the tail log backup. NO_TRUNCATE might be necessary. Restore the damaged filegroup(s) using the filegroup backup or a Full backup with the FILEGROUP clause. Putting the db offline/online could be necessary. If you had to offline/online the db, take another tail log backup! Restore log backups to roll forward the affected filegroup until you’re done with the tail.
RESTORE a specific damaged FILE Ingredients: Database in FULL recovery mode. Full backup or individual Filegroup backups (preferable). Log backups. Sequence: Take the tail log backup. NO_TRUNCATE might be necessary. Restore the damaged filegroup(s) using the filegroup backup or a Full backup with the FILE clause. Putting the db offline/online could be necessary. If you had to offline/online the db, take another tail log backup! Restore log backups to roll forward the affected filegroup until you’re done with the tail.
RESTORE a damaged PAGE Ingredients: Sequence: Database in FULL recovery mode. Filegroup must be read-write. Full backup or individual Filegroup backups (preferable). Log backups. Sequence: Restore the damaged page(s) with a filegroup backup or a Full backup. Take the tail log backup. Restore log backups to roll forward the affected filegroup until you’re done with the tail.
Recover from losing the Transaction Log The #1 option is to restore from backups. If there are no backups (shame on you!), emergency mode…. Ingredients: The system stakeholders are aware of possible loss of data and general inconsistency by going this route. Luck, faith, an up-to-date resume. Sequence: Run an ALTER DATABASE * SET EMERGENCY Run a DBCC CHECKDB REPAIR_ALLOW_DATA_LOSS (SINGLE_USER is needed) Run an ALTER DATABASE * SET MULTI_USER
Standard Edition IMPORTANT NOTE: Standard Edition will support these RESTORE scenarios in OFFLINE mode only. ONLINE mode is Enterprise only.
Recap Go over your environment and the possible scenarios you could face and come up with your own recipes. Get a test machine and run the scenarios yourself. Document the steps. If there’s a change in db layout, infrastructure or backup solution, revisit your recipes.
Questions?
Download package available here: http://sqlturbo