Solved

Backup->Restore SQLServer05 to ANOTHER machine

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Parsing the XML data to SQL Server 4 70
SQL 2005 - Memory Table Column Names 11 81
Bubble user-defined Sql RAISERROR(...) to c# exception 14 202
What is this datetime? 1 26
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 …
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

763 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