How to properly restore a SQL instance in a new server?


I am currently backing up some databases in a SQL instance. Between the databases that I am backing up are the "model" and "master" default databases.

My question comes when recovering these databases including the model and master, how is it that I should recover them in a new SQL server?

Should I overwrite the "model" and "master" databases on this new SQL server?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vitor MontalvãoMSSQL Senior EngineerCommented:
Do you know what are in those system databases?
Master has information about the server, logins and databases of the instance.
Model has information about the jobs and packages.

I would be very, very careful in restoring those databases in another instance. Be sure that the new instance has the same release has the previous one.

If you can export the logins, jobs and packages then it would be better. Even it's a task that take longer than restoring the databases.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Scott PletcherSenior DBACommented:
It's easiest to restore an entire instance to the exact same version of SQL Server, with the same service packs, patches, etc.  

If you have such a new instance ready to go on the new server, use these steps:
1) Stop SQL
2) Copy the system files -- master, model, msdb -- over the existing ones (this is faster than restoring, although you can do restores instead)
3) Start up SQL
It's vastly easier to do actual restores than to try to duplicate what is in them in new system dbs.

When SQL starts back up with the new system dbs, you will get a lot of errors about user dbs -- you can ignore those.  Restore your user dbs -- specifically CREATE DATABASE ... WITH ATTACH -- in whatever order you want.  As you do those restores, the user db errors will go away.
LuiLui77Author Commented:
Thank you Gentlemen for your posts!

Scott, when you refer to "user dbs", are you referring to a database named "user" or the master database that contains the logins? also, when you say "CREATE DATABASE ... WITH ATTACH" is that an option to recover?

Sorry for inexperience!
Scott PletcherSenior DBACommented:
"User dbs" are all the non-system dbs.  System dbs are master, model, msdb and tempdb.  (If replication is being used, you might also have a db named "distribution", or even multiple distribution dbs with whatever names the person setting up replication chose).  

Yes, the "CREATE DATABASE ... WITH ATTACH" is one of way of taking existing db files, copying them to this new server, and then bringing that user db up in the new instance.  Other methods would be restore, which is perfectly accept, and sp_attach_db, which is obsolete and should not be used.
LuiLui77Author Commented:
Thank you
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.