SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


DataBase Restore


DataBase Restore

Author
Message
Brian Shafer
Brian Shafer
SSC Rookie
SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)

Group: General Forum Members
Points: 35 Visits: 22

Hi,

I have a database that I backup each day as a scheduled job the syntax is as follows:

BACKUP DATABASE [master] TO DISK = N'D:\SQL Data Files\RSMS\Backups\Master.bak' WITH INIT , NOUNLOAD , NOSKIP , STATS = 10, NOFORMAT

BACKUP DATABASE [msdb] TO DISK = N'D:\SQL Data Files\RSMS\Backups\msdb.bak' WITH INIT , NOUNLOAD , NOSKIP , STATS = 10, NOFORMAT

BACKUP DATABASE [model] TO DISK = N'D:\SQL Data Files\RSMS\Backups\model.bak' WITH INIT , NOUNLOAD , NOSKIP , STATS = 10, NOFORMAT


BACKUP DATABASE [rsms] TO DISK = N'D:\SQL Data Files\RSMS\Backups\RSMS.bak' WITH INIT , NOUNLOAD , NOSKIP , STATS = 10, NOFORMAT


BACKUP LOG [RSMS] TO DISK = N'D:\SQL Data Files\RSMS\Backups\RSMS.TRN' WITH INIT

Databases are in Recovery mode:

Master: Full

Model: Full

MSDB: Simple

RSMS: Full

Then later on that night, the IS department does a online tape backup of the drives.

I created a test system and want to restore my databases. I keep coming up with errors. It says I need to "Move" the files, but then I try to attach and it gives me an invalid database file? What is the proper way to do this?

Thanks,

Brian


SQLBill
SQLBill
SSCarpal Tunnel
SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)

Group: General Forum Members
Points: 4931 Visits: 1075
So you aren't doing the restore on the original system?

Did you copy the tape backup to the same drive location as on the original server (to N'D:\SQL Data Files\RSMS\Backups)? If not, you need to do so. Or use the MOVE option in your restore command. Refer to the BOL for how to use MOVE with RESTORE DATABASE.

-SQLBill



ramses2nd
ramses2nd
SSC-Addicted
SSC-Addicted (410 reputation)SSC-Addicted (410 reputation)SSC-Addicted (410 reputation)SSC-Addicted (410 reputation)SSC-Addicted (410 reputation)SSC-Addicted (410 reputation)SSC-Addicted (410 reputation)SSC-Addicted (410 reputation)

Group: General Forum Members
Points: 410 Visits: 294

A with Move error usually means that the database restore is trying to put the data and log file in the same location as the server that it was backed up from. For example, on one server we store our data files on the root of E:\ on another server they are stored at d:\data\. If I try to restore a backup from the first server to the second it will try to put the files at E:\. If that location does not exist then I will get an error telling me to use the with move clause. The syntax I use is as follows:

RESTORE DATABASE [dbname] FROM DISK = 'path to backup file'

WITH FILE = 1, NOUNLOAD , STATS = 10, RECOVERY , REPLACE ,

MOVE 'nameofdatafile' TO 'new physical location of the data file',

MOVE 'nameoflogfile' TO 'new physical location of the log file'





Brian Shafer
Brian Shafer
SSC Rookie
SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)

Group: General Forum Members
Points: 35 Visits: 22

sqlbill,

No I am trying to restore on a test system. You referred to "BOL", what is "BOL"?

ramses2nd,

I will try that. And I should restore each file like that, with the exception of the log file "restore log". and I should do that last?

Thanks,

Brian


Brian Shafer
Brian Shafer
SSC Rookie
SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)

Group: General Forum Members
Points: 35 Visits: 22

Hi,

when I run this scrip I get the error that is included..

RESTORE DATABASE [RSMS] FROM DISK = 'C:\Temp\RS_Server Backups\rsms.bak'
WITH FILE = 1, NOUNLOAD , STATS = 10, RECOVERY , REPLACE ,
MOVE 'RSC_DATA' TO 'D:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\',
MOVE 'RSC_LOG' TO 'D:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\'

Server: Msg 3176, Level 16, State 1, Line 1
File 'D:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\' is claimed by 'Rsc_Log'(2) and 'Rsc_Data'(1). The WITH MOVE clause can be used to relocate one or more files.
Server: Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.

Any Help?


Brian Shafer
Brian Shafer
SSC Rookie
SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)

Group: General Forum Members
Points: 35 Visits: 22
Never Mind.. I got it.. forgot the file name on the move...
Rudyx - the Doctor
Rudyx - the Doctor
SSCarpal Tunnel
SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)

Group: General Forum Members
Points: 4735 Visits: 2503

One point that was missed ... it concerns recovery ...

Databases are in Recovery mode:

  • Master: Full ---> this should be simple
  • Model: Full-----> it is simple by default
  • MSDB: Simple
  • RSMS: Full

Modification of recovery modes for the system databases is not recommended nor supported. The one exception is the model database. However changing the recovery mode of the master database is definitely a no-no.



Regards
Rudy Komacsar
Senior Database Administrator

"Ave Caesar! - Morituri te salutamus."
Jason Hall
Jason Hall
Mr or Mrs. 500
Mr or Mrs. 500 (500 reputation)Mr or Mrs. 500 (500 reputation)Mr or Mrs. 500 (500 reputation)Mr or Mrs. 500 (500 reputation)Mr or Mrs. 500 (500 reputation)Mr or Mrs. 500 (500 reputation)Mr or Mrs. 500 (500 reputation)Mr or Mrs. 500 (500 reputation)

Group: General Forum Members
Points: 500 Visits: 82
I certaintly agree with Rudy. Most of my user databases are in full recovery so I have model set to full however I would strongly recommend that you do not put master or msdb in full recovery.
Brian Shafer
Brian Shafer
SSC Rookie
SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)

Group: General Forum Members
Points: 35 Visits: 22

Can you explain to me why it is not recommended? I hope to understand this, so if you have a few more minutes


Rudyx - the Doctor
Rudyx - the Doctor
SSCarpal Tunnel
SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)

Group: General Forum Members
Points: 4735 Visits: 2503
Modification of recovery modes for the system databases is not recommended nor supported.

Regards
Rudy Komacsar
Senior Database Administrator

"Ave Caesar! - Morituri te salutamus."
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search