Solved

Backup->Restore SQLServer05 to ANOTHER machine

Posted on 2007-04-04
4
220 Views
Last Modified: 2010-03-19
What is the simplest way to backup a SQLServer 2005 DB so that I'm able to restore it on ANOTHER machine and DB matching the same schema?

If I run the built in backup task, it won't restore to any other machine except the one that originated the backup...which is pretty useless if the harddrive crashes...

Why don't they offer a simply SQL dump of structure AND data like MySQL offers?
0
Comment
Question by:tradeline
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 18852243
take a backup, copy it on the other server, restore from the above  copy

BACKUP DATABASE urDBName
TO DISK = 'C:\urDb.bak'
--now copy it to say  C:\  drive

RESTORE DATABASE NewDatabaseName
FROM DISK = 'C:\urDB.Bak'
0
 
LVL 16

Accepted Solution

by:
rboyd56 earned 500 total points
ID: 18853003
aneeshattingal's solution is correct. However you may need to use the WITH MOVE parameter to changg the location of the files to an appropriate location on the new machine. The path to the data and log files are stored in the backup file and if the path on the original server does not exist on the new server you will get an error. So the WITH MOVE parameter allows you to overcome this

Example from Books on Line:

RESTORE DATABASE MyNwind
   FROM MyNwind_1
   WITH NORECOVERY,
      MOVE 'MyNwind' TO 'c:\Program Files\Microsoft SQL Server\MSSQL\Data\NewNwind.mdf',
      MOVE 'MyNwindLog1' TO 'c:\Program Files\Microsoft SQL Server\MSSQL\Data\NewNwind.ldf'
RESTORE LOG MyNwind
   FROM MyNwindLog1
   WITH RECOVERY
0
 

Author Comment

by:tradeline
ID: 18948332
rboyd56:

I accepted your comment too soon I'm afraid :).  Your solution yields the same results I've always experienced:

ERROR: The backup set holds a backup of a database other than the existing 'NewDBTest' database.

I used the following code, maybe I've misunderstood something?

RESTORE DATABASE NewDBName
   FROM DISK = 'C:\OldDB.bak'
   WITH NORECOVERY,
      MOVE 'OldDBName' TO 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\NewDBName.mdf',
      MOVE 'OldDBName_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\NewDBName_log.ldf'

Previously I wasn't restoring from SQL, but using the wizard inside SqlServer2005...the error is the same.  It is only allowing me to restore to the SAME database that was the source of the backup.

Thanks.
0
 

Author Comment

by:tradeline
ID: 18948475
Solved it:

I'm not sure what the SQL syntax is, but I achieved the same result in the options area of the restore UI, by selecting "Overwrite existing database", and then changing the paths from those on the webserver to those locally.

Thanks again.
0

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

726 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