DataBase Restore

  • 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

  • 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

  • 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'

  • 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

  • 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?

  • Never Mind.. I got it.. forgot the file name on the move...

  • 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.

    RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."

  • 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.

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

  • Modification of recovery modes for the system databases is not recommended nor supported.

    RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."

  • Master is the "heart" of your SQL installation   It's hard enough to restore a backup of it - I can only imagine the flaming hoops you would have to jump through to restore additional transaction log backups of it

  • BOL is the Books on Line. The SQL Server Help files.

    -SQLBill

  • So, if the Master is the Heart of the database, then, my database is not completly restored, untill I restore it?  Does not body restore the master, or do they just have scripts to recreate the tasks and sercurity login's?

    Brian

  • No. The heart is the only organ non-transplantable in this analogy. Restoration of a user database is like receiving a new kidney, again in this analogy.

    RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."

  • hahaha

    Sorry, meant to say it was like the central part of your SQL Server installation.  It itself is essentially another database on SQL, but it must always be there and stores all of your logins, system settings and lists of your other SQL Server databases.. 

Viewing 15 posts - 1 through 15 (of 21 total)

You must be logged in to reply to this topic. Login to reply