Groups | Blog | Home
all groups > sql server new users > march 2005 >

sql server new users : Backup-Restore Script


Brian Branco
3/2/2005 9:35:35 PM
I am new at this and I am stuck...

I am trying to backup an entire database and restore it on the same SQL
server with a different name.

I have this in the Query Analyzer
BACKUP DATABASE merchant
TO DISK = 'c:\merchant.bak'
RESTORE FILELISTONLY
FROM DISK = 'c:\merchant.bak'
RESTORE DATABASE TestDB
FROM DISK = 'c:\merchant.bak'
WITH MOVE 'merchant' TO 'c:\testdb.mdf',
MOVE 'merchant_log' TO 'c:\testdb.ldf'
GO

I get the following error

Processed 2304 pages for database 'merchant', file 'Struky3_Data' on file
13.
Processed 1 pages for database 'merchant', file 'Struky3_Log' on file 13.
BACKUP DATABASE successfully processed 2305 pages in 2.539 seconds (7.434
MB/sec).

(2 row(s) affected)

Server: Msg 3234, Level 16, State 2, Line 5
Logical file 'merchant' is not part of database 'TestDB'. Use RESTORE
FILELISTONLY to list the logical file names.
Server: Msg 3013, Level 16, State 1, Line 5
RESTORE DATABASE is terminating abnormally.


Can anyone help with this?

I want to copy the entire database called MERCHANT to another database

Tom Moreau
3/2/2005 9:42:39 PM
When you ran:

RESTORE FILELISTONLY
FROM DISK = 'c:\merchant.bak'

.... what was the output? Failing that, run:

merchant.dbo.sp_helpfile

It should list the logical file names, as well as the physical names.

--
Tom

----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com
..
[quoted text, click to view]
I am new at this and I am stuck...

I am trying to backup an entire database and restore it on the same SQL
server with a different name.

I have this in the Query Analyzer
BACKUP DATABASE merchant
TO DISK = 'c:\merchant.bak'
RESTORE FILELISTONLY
FROM DISK = 'c:\merchant.bak'
RESTORE DATABASE TestDB
FROM DISK = 'c:\merchant.bak'
WITH MOVE 'merchant' TO 'c:\testdb.mdf',
MOVE 'merchant_log' TO 'c:\testdb.ldf'
GO

I get the following error

Processed 2304 pages for database 'merchant', file 'Struky3_Data' on file
13.
Processed 1 pages for database 'merchant', file 'Struky3_Log' on file 13.
BACKUP DATABASE successfully processed 2305 pages in 2.539 seconds (7.434
MB/sec).

(2 row(s) affected)

Server: Msg 3234, Level 16, State 2, Line 5
Logical file 'merchant' is not part of database 'TestDB'. Use RESTORE
FILELISTONLY to list the logical file names.
Server: Msg 3013, Level 16, State 1, Line 5
RESTORE DATABASE is terminating abnormally.


Can anyone help with this?

I want to copy the entire database called MERCHANT to another database

Brian Branco
3/2/2005 10:00:56 PM
The logical file name is: STRUCKY3, the physical name is merchant.

Thanks...


[quoted text, click to view]

Steen Persson
3/3/2005 9:31:47 AM
You need to specify the Logical file name instead of the physical name when
your restore with the MOVE option.

RESTORE DATABASE TestDB
FROM DISK = 'c:\merchant.bak'
WITH MOVE 'strucky3_data' TO 'c:\testdb.mdf',
MOVE 'strucky3_log' TO 'c:\testdb.ldf'

(...here I assume that the logical file name for the data file is
'strucky3_data' and the logfile is 'strucky3_log', but that's what you can
get from the RESTORE FILELISTONLY command).

You can also look up the RESTORE command in BOL.

Regards
Steen



[quoted text, click to view]

AddThis Social Bookmark Button