Solved

Backup->Restore SQLServer05 to ANOTHER machine

Posted on 2007-04-04
4
203 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
  • 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Query 2 63
Sql Permission 6 67
How do i Copy All the Tables from One Database to Another in SQL Server? 7 48
How to use TOP 1 in a T-SQL sub-query? 14 48
Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

832 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