Restore Procedures:
- Complete Media Restore (CMR):
* Restores all database files, including data and log files.
* Replaces the existing database files with new ones from the backup set.
* Example: Restoring a SQL Server database from a complete media backup after a server crash.
Example Steps:
- Verify that the backup is available and meets the required criteria for restore (e.g., correct version, compatible hardware).
- Shutdown the SQL Server service to prevent any concurrent operations.
- Open the SQL Server Management Studio (SSMS) or SQLcmd utility as an administrator.
- Select the database to be restored from the "Restore Database" option in SSMS or use the
RESTORE DATABASE command in SQLcmd. - Specify the backup set to restore from, including the path and file name of the backup file.
Example SQLcmd syntax:
sql
RESTORE DATABASE MyDatabase FROM DISK = 'C:\Backups\MyDatabase.bak'
WITH REPLACE;
- Piecemeal Restore (PMR):
* Restores only specific database files or objects, rather than the entire database.
* Used to restore individual tables, indexes, or other database components.
Example Steps:
- Identify the specific database component(s) to be restored (e.g., a table or index).
- Use the
RESTORE TABLE command in SQLcmd or select the "Restore Object" option in SSMS. - Specify the backup set and location of the relevant data file.
Example SQLcmd syntax:
sql
RESTORE TABLE MyTable FROM DISK = 'C:\Backups\MyDatabase.bak' WITH REPLACE;
Partial Media Restore (PMR):
* Restores only a portion of the database, typically after a media failure.
* Used when some, but not all, data files are corrupted or unavailable.
Example Steps:
- Identify the damaged or missing database components and assess their impact on overall system availability.
- Take a new backup of the unaffected database components.
- Perform a piecemeal restore to replace the missing or damaged components with the new backups.
- Once complete, perform a final complete media restore (CMR) to ensure consistency across all data files.
Example SQLcmd syntax:
sql
-- Backup unaffected components
BACKUP TABLE MyUnaffectedTable TO DISK = 'C:\Backups\MyUnaffectedTable.bak';-- Perform piecemeal restore of missing component
RESTORE TABLE MyMissingTable FROM DISK = 'C:\Backups\MyMissingTable.bak' WITH REPLACE;
-- Final complete media restore (CMR)
RESTORE DATABASE MyDatabase FROM DISK = 'C:\Backups\MyDatabase.bak' WITH REPLACE;
Please note that these are simplified examples, and actual procedures may vary depending on the specific database management system and backup tools used.