To restore a database you need to do three things:
- Install MS SQL Server Express
- Interrogate the backup file to find the logical file names it contains
- Restore the file into the appropriate database
Assume: For this example, the backup file is C:\Backups\DB_Backup_20110131.bak
Step 1: Install MS SQL Server
Go to Micro$oft site using the direct link http://www.microsoft.com/express/Database/I-nstallOptions.aspx and download and install the most appropriate version of SQL Server Express.
Step 2: Interrogate Backup File
RESTORE FILELISTONLY FROM DISK = 'C:\Backups\DB_Backup_20110131.bak'
This will return something like the below set of rows which represent the internal logical composition of the backup file:
LogicalName PhysicalName Type FileGroupName Size MaxSize ------------------ ---------------------------- ---- ------------- --------- -------------- SourceDatabase_data C:\SqlServer\Src_DB_Data.mdf D PRIMARY 836461765 35184372080640 SourceDatabase_log C:\SqlServer\Src_DB_Log.ldf L NULL 91592723 35184372080640
Step 3: Restore from Backup File
RESTORE DATABASE Destination_DB FROM DISK = 'C:\Backups\DB_Backup_20110131.bak' WITH REPLACE, -- Overwrite DB - if one exists RECOVERY, -- Use if this is the only file to recover STATS = 10, -- Show progress (every 10%) MOVE 'SourceDatabase_data' TO 'C:\SqlServer\Src_DB_Data.mdf', MOVE 'SourceDatabase_log' TO 'C:\SqlServer\Src_DB_Data.mdf'
No comments:
Post a Comment