Transcript Slide 1

The Restore Cookbook
SQLSaturday Ottawa 2015
Warner Chaves
MCM / MVP / SQLTurbo.com / Pythian.com
1
1
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: [email protected]
• Blog: sqlturbo.com
• Company: Pythian.com
2
2
Agenda
Objective: present different RESTORE scenarios in the form of
recipes: easy to remember, to reference and repeat.
 Scenarios we’ll visit:
1.
2.
3.
4.
3
RESTORE of a damaged FILEGROUP.
RESTORE of a specific damaged FILE.
RESTORE of a damaged PAGE.
Recover from losing the Transaction Log.
3
RESTORE a damaged FILEGROUP
• Ingredients:
• Database in FULL recovery mode.
• Full backup or individual Filegroup backups (preferable).
• Log backups.
• Sequence:
1. Take the tail log backup. NO_TRUNCATE might be necessary.
2. 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.
3. If you had to offline/online the db, take another tail log backup!
4. Restore log backups to roll forward the affected filegroup until you’re done with the tail.
4
4
RESTORE a specific damaged FILE
• Ingredients:
• Database in FULL recovery mode.
• Full backup or individual Filegroup backups (preferable).
• Log backups.
• Sequence:
1. Take the tail log backup. NO_TRUNCATE might be necessary.
2. 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.
3. If you had to offline/online the db, take another tail log backup!
4. Restore log backups to roll forward the affected filegroup until you’re done with the tail.
5
5
RESTORE a damaged PAGE
• Ingredients:
• Database in FULL recovery mode.
• Filegroup must be read-write.
• Full backup or individual Filegroup backups (preferable).
• Log backups.
• Sequence:
1. Restore the damaged page(s) with a filegroup backup or a Full backup.
2. Take the tail log backup.
3. Restore log backups to roll forward the affected filegroup until you’re done with the tail.
6
6
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:
1.
Run an ALTER DATABASE * SET EMERGENCY
2.
Run a DBCC CHECKDB REPAIR_ALLOW_DATA_LOSS (SINGLE_USER is needed)
3.
Run an ALTER DATABASE * SET MULTI_USER
7
7
Standard Edition
IMPORTANT NOTE: Standard Edition will support these RESTORE
scenarios in OFFLINE mode only.
ONLINE mode is Enterprise only.
8
8
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.
9
9
Questions?
10
10
Download package available here:
http://sqlturbo.com/presentation-sql-server-restorecookbook/
11
11