Selected topic

Restore Procedures

Backup And Recovery

Prefer practical output? Use related tools below while reading.

Restore Procedures:

  1. 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:

  1. Verify that the backup is available and meets the required criteria for restore (e.g., correct version, compatible hardware).
  2. Shutdown the SQL Server service to prevent any concurrent operations.
  3. Open the SQL Server Management Studio (SSMS) or SQLcmd utility as an administrator.
  4. Select the database to be restored from the "Restore Database" option in SSMS or use the RESTORE DATABASE command in SQLcmd.
  5. 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;
  1. 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:

  1. Identify the specific database component(s) to be restored (e.g., a table or index).
  2. Use the RESTORE TABLE command in SQLcmd or select the "Restore Object" option in SSMS.
  3. 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:

  1. Identify the damaged or missing database components and assess their impact on overall system availability.
  2. Take a new backup of the unaffected database components.
  3. Perform a piecemeal restore to replace the missing or damaged components with the new backups.
  4. 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.