Search
Home
Articles
Backup
Books
Certification
FAQ
Products
Replication
Scripts
Seminars
Training
TSQL

MSDN Fourms
Philippine SSUG
Fort Worth SSUG
Oklahoma City SSDG

Resume

MHS Enterprises
BlowFrog Software
FilAm Software
AcrylicAcetate.com
Bargain Humidors
Western Humidor

Backup Overview 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

Restoring a file or filegroup

The full command to restore a file or filegroup is as follows with the options as described previously.

RESTORE DATABASE {database_name | @database_name_var} <file_or_filegroup> [,...n][FROM <backup_device> [,...n]][WITH
[DBO_ONLY][[,] FILE = file_number][[,] MEDIANAME = {media_name | @media_name_variable}][[,] NORECOVERY][[,] {NOUNLOAD | UNLOAD}][[,] REPLACE][[,] RESTART][[,] STATS [= percentage]]

This boils down to the following command:

restore database <file or filegroup> from <device> with <options>

Restore from an explicit disk device

restore database pubs file = ‘pubsdata_1’ from diskbackup

Restore from an undefined network disk device and overwrite the existing file

restore database file = ‘pubsdata_1’ from disk = ‘\\myserver\dbbackups\pubs.bak’ with replace

Restore from a tape device and leave the tape in the drive

restore database file = ‘pubsdata_1’ from tapebackup with nounload

Restore multiple filegroups from a tape device and do not recover due to transaction logs being applied

restore database filegroup = ‘authordata’, filegroup = ‘authorindexes’, filegroup = ‘authorimages’ from tapebackup with norecovery

Restoring a differential backup

Restoring a differential backup utilizes the same command and syntax and a full database restore.

Restoring a transaction log

The command to restore a transaction log is as follows with the options as noted in the table above with execptions noted below:
RESTORE LOG {database_name | @database_name_var}[FROM <backup_device> [,...n]][WITH [DBO_ONLY][[,] FILE = file_number]
[[,] MEDIANAME = {media_name | @media_name_variable}][[,] {NORECOVERY | RECOVERY | STANDBY = undo_file_name}][[,] {NOUNLOAD | UNLOAD}][[,] RESTART][[,] STATS [= percentage]][[,] STOPAT = {date_time | @date_time_var}]]

The stopat option allows for a point in time restore of the transaction log. This is normally used if you know the transaction log got corrupted at some point or commands were issued after a specific time that you do not want applied.

This boils down to the following command:

restore log <database name> from <device> with <options>

Restore a log from an explicit disk device

restore log pubs from tranbackup

Restore log from an undefined network disk device using the third file in the backup

restore log pubs from disk = ‘\\myserver\tranbackups\pubs.bak’ with file = 3

Restore multiple logs from a tape device and leave the tape in the drive

restore log pubs from tapebackup with file = 1, norecovery

restore log pubs from tapebackup with file = 2, norecovery

restore log pubs from tapebackup with file = 3, recovery

Backup Overview 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

Michael R. Hotek

All content on this site, except where noted, represents an original work of Michael R. Hotek and is protected by applicable copyright laws. The SQL Server FAQ is the sole work of Neil Pike. No page, portion of a page, or download may be used for commercial purposes in whole or in part without the express, written permission of the applicable author.