Solved

Backup->Restore SQLServer05 to ANOTHER machine

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now