Tuesday, March 20, 2012

rebuild a database from backupfile only?

Hello Rainer,
I understand that you cannot restore a database when the existing mdf/ldf
is remmoved and the database does not exist on the server. If I'm off-base,
please let me know.
You may first run fist command:
restore headeronly FROM DISK = N'C:\Program Files\Microsoft SQL
Server\MSSQL.3\MSSQL\Backup\dbacc.bak'
Please see the Databasename in the result, and this shall be the database
name you use in restore command. Please double check the name is correct.
From the error message you encounter, it seems the database name is not
correct in your restore command
In my sample, it is dbacc. If run the command you mentioned, you may see
the following error message:
RESTORE DATABASE [dbacc] FROM DISK = N'C:\Program Files\Microsoft SQL
Server\MSSQL.3\MSSQL\Backup\dbacc.bak' WITH FILE = 1,
NORECOVERY, REPLACE, NOUNLOAD, STATS = 10
Msg 5133, Level 16, State 1, Line 1
Directory lookup for the file "E:\sql2005\MSSQL.1\MSSQL\DATA\dbacc.mdf"
failed with the operating system error 3(The system cannot find the path
specified.).
Msg 3156, Level 16, State 3, Line 1
File 'dbacc' cannot be restored to
'E:\sql2005\MSSQL.1\MSSQL\DATA\dbacc.mdf'. Use WITH MOVE to identify a
valid location for the file.
Msg 5133, Level 16, State 1, Line 1
Directory lookup for the file "E:\sql2005\MSSQL.1\MSSQL\DATA\dbacc_log.ldf"
failed with the operating system error 3(The system cannot find the path
specified.).
Msg 3156, Level 16, State 3, Line 1
File 'dbacc_log' cannot be restored to
'E:\sql2005\MSSQL.1\MSSQL\DATA\dbacc_log.ldf'. Use WITH MOVE to identify a
valid location for the file.
Msg 3119, Level 16, State 1, Line 1
Problems were identified while planning for the RESTORE statement. Previous
messages provide details.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
If so, you need to use "with move" statmend in restore command. For example:
RESTORE DATABASE [dbacc] FROM DISK = N'C:\Program Files\Microsoft SQL
Server\MSSQL.3\MSSQL\Backup\dbacc.bak' WITH FILE = 1,
NORECOVERY, REPLACE, NOUNLOAD, STATS = 10,
move 'dbacc' to 'C:\Program Files\Microsoft SQL
Server\MSSQL.3\MSSQL\Backup\dbacc.mdf',
move 'dbacc_log' to 'C:\Program Files\Microsoft SQL
Server\MSSQL.3\MSSQL\Backup\dbacc_log.ldf'
If the issue still occurs, it might be the backup file is corrupted. You
may want to try a new backup/restore to test. Also, you may want to test
directly in QA or mangement studio(2005) to see if there is any difference
More related informaiton:
Moving SQL Server 7.0 databases to a new server with BACKUP and RESTORE
http://support.microsoft.com/kb/304692/
314546 HOW TO: Move Databases Between Computers That Are Running SQL Server
http://support.microsoft.com/?id=314546
Please let's know if you have any further questions or concerns. Thanks.
Best Regards,
Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications
<http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx>.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
<http://msdn.microsoft.com/subscriptions/support/default.aspx>.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Hello Rainer,
Please feel free to post back if you have any update. :-)
Best Regards,
Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
================================================== ===
This posting is provided "AS IS" with no warranties, and confers no rights.

No comments:

Post a Comment