Solved

DB restore

Posted on 2006-11-16
13
501 Views
Last Modified: 2012-06-27
Not want to affect the online DB, can I restore the backup DB to another folder with another name by sql.
0
Comment
Question by:turbot_yu
  • 7
  • 5
13 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17954914
restore database 'NewName'
FROM disk = 'CompletePath'
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17954924
Sorry

    restore database 'NewName'
FROM disk = 'CompletePath'
WITH MOVE 'urMdfPhysicalName' TO 'c:\test\MdfFile.mdf',
   MOVE 'urLogPhysicalName' TO 'c:\test\LogFile.ldf'
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17954928
In order to get the Physical name use

RESTORE FILELIST ONLY
WITH DISK ='Complete path of ur backUp file '
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 20

Expert Comment

by:Sirees
ID: 17955588
Check "Restoring a Complete Backup to a New Database on the Same Server" and "Restoring a Complete Backup to a New Server"
from this link

http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/sqlbackuprest.mspx#EMMAC
0
 

Author Comment

by:turbot_yu
ID: 17963059
I tried to

RESTORE DATABASE ming_new_by_sql FROM DISK = 'd:\db\BACKUP\mings.Bak'
WITH MOVE 'ming' TO 'd:\db\ming_bk.mdf'
MOVE 'ming_log' TO 'd:\dbming_bk_log.ldf'

but get error with

Msg 102, Level 15, State 1, Line 3
Incorrect syntax near 'MOVE'.

Any suggestion?
0
 

Author Comment

by:turbot_yu
ID: 17963081
I tried

RESTORE FILELIST ONLY
WITH DISK ='d:\db\BACKUP\ming.Bak'

but error

Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'FILELIST'.
Msg 319, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon.

0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17963094
I am sorry , try with  'FILELISTONLY' (no space b/e those 2 words )


Here is an Example from Books online

This example creates a new database called MyNwind2_Test. MyNwind2_Test is a copy of the existing MyNwind2 database that comprises two files: MyNwind2_data and MyNwind2_log. Because the MyNwind2 database already exists, the files in the backup need to be moved during the restore operation. The RESTORE FILELISTONLY statement is used to determine the number and names of the files in the database being restored.

USE master
GO
-- First determine the number and names of the files in the backup.
-- MyNwind_2 is the name of the backup device.
RESTORE FILELISTONLY
   FROM MyNwind_2
-- Restore the files for MyNwind2_Test.
RESTORE DATABASE MyNwind2_Test
   FROM MyNwind_2
   WITH RECOVERY,
   MOVE 'MyNwind2_data' TO 'D:\MyData\MyNwind2_Test_data.mdf',
   MOVE 'MyNwind2_log' TO 'D:\MyData\MyNwind2_Test_log.ldf'
GO


0
 

Author Comment

by:turbot_yu
ID: 17963217
Now I use the command below to backup, how to restore from ming.bak

USE ming
GO
BACKUP DATABASE ming
TO DISK = 'd:\db\BACKUP\ming.Bak'
GO


Online DB file: d:\db\ming.mdf and  d:\db\ming.ldf
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17963231
Step1.  find the physical filenames

RESTORE FILELISTONLY
FROM  DISK = 'd:\db\BACKUP\ming.Bak'


Say it gave me the files as  Ming_Data  and Ming_log.

Step2 : restore the database as a new name

RESTORE DATABASE Ming_Test
   FROM MyNwind_2
   WITH RECOVERY,
   MOVE 'Ming_data' TO 'D:\MyData\Ming_Test_data.mdf',
   MOVE 'Ming_log'  TO 'D:\MyData\Ming_Test_log.ldf'
GO
0
 

Author Comment

by:turbot_yu
ID: 17963305
I tried

RESTORE DATABASE ming_test
   FROM ming
   WITH RECOVERY,
   MOVE 'Ming' TO 'D:\db\Ming_Test_data.mdf',
   MOVE 'Ming_log'  TO 'D:\db\Ming_Test_log.ldf'
GO


got:

Msg 3206, Level 16, State 1, Line 1
No entry in sysdevices for backup device 'ming'. Update sysdevices and rerun statement.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
0
 

Author Comment

by:turbot_yu
ID: 17963312
use
RESTORE FILELISTONLY
FROM  DISK = 'd:\db\BACKUP\ming.Bak'


got

ming      D:\DB\ming.mdf      D      PRIMARY      2097152      35184372080640      1      0      0      3ED48254-3414-4A20-B79E-8099EA31F3AC      0      0      1376256      512      1      NULL      18000000024400092      54374E32-4B54-490F-82A3-3FF89BE68869      0      1
ming_log      D:\DB\ming_log.ldf      L      NULL      1310720      2199023255552      2      0      0      84604128-9BC9-43F4-A872-99D31E4DDC32      0      0      0      512      0      NULL      0      00000000-0000-0000-0000-000000000000      0      1
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17963421
oops sorry ...
This will work

RESTORE DATABASE ming_test
   FROM DISK = 'd:\db\BACKUP\ming.Bak' ------------------<---ming
   WITH RECOVERY,
   MOVE 'Ming' TO 'D:\db\Ming_Test_data.mdf',
   MOVE 'Ming_log'  TO 'D:\db\Ming_Test_log.ldf'
0
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 17963440
FYI
RESTORE DATABASE ming_test FROM
   DISK = 'd:\db\BACKUP\ming.Bak' -- this is the Backup location, in your case backup is on Disk so yu need to put the path of the filename also
   WITH RECOVERY,
   MOVE 'Ming' TO 'D:\db\Ming_Test_data.mdf',  ------------ 'Ming' is the name of your datafile (the first column value u get when u run the RESTORE FILELISTONLY
   MOVE 'Ming_log'  TO 'D:\db\Ming_Test_log.ldf' ------------
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question