Login  Register 
September 05, 2010
:: Resources» Fingerfuel Blogs» Andy Hock's Blog   Search
Search
  
Andy Hock's Technology Blog
Feb 14

Written by: Andy Hock
2/14/2007 1:56 PM

I've had a number of people ask me how to go about making a complete copy of a database. Since I've seen it explained elsewhere, but always in techy ways, I thought I'd give an English step-by-step explanation of how to do this.


It's a critical step to do every one in a while, and especially before you perform any upgrades, run system stored procedures, etc..


To create a copy of your database, take the following steps:


1. Click Start->Programs->SQL Server 2000 -> Enterprise Manager (EM)

2. Once EM is running, click on the 'tree control' on the left side, and drill down to Databases->'Your DNN Database'.

3. Right click on 'Your DNN Database' (whatever name you gave it).

4. Select All Tasks -> Detach Database.

5. Step through the wizard and follow the instructions. If there are users, I would log them out w/o a reply (the reply can take up to 20 minutes or so...so if this is a live site I would perform this task late at night or when the site is slow).

6. Your database is now detached and you can copy the actual files to have a true copy of the database.

 

7. Find out where SQL Server is storing the data. The default is something like C:\Program Files\Microsoft SQL Server\8.0\SQL Data\ MSSQL\Data\ (I put my data in a different folder than the default, so there might not be a 'SQL Data' folder)

8. find the .mdf and one or more .ldf files that are named with your database name and copy them to another folder.


Now, once you have a copy of the database, you can reattach it and do whatever damage you want to it, knowing you have an exact copy which you can reattach if things get messed up.


To re-attach a database do the following:


Repeat steps 1-2 above.

3. Right click on the 'Databases' tree node.

4. Select All Tasks -> Attach Database.

5. Follow the wizard instructions. The two important things to know here are that you know where the .mdf file is (which of course you have to know if you want to detach it and copy it!), and that you select the same db owner that you had before (this is not a critical thing, but helpful. Just look in your web.config file and use whatever is *that* username as the db owner in the attach database wizard and you'll be good to go).


Even if you do not have access to EM, just tell your ISP to do the above, zip the copied mdf and ldf files up and put them in a folder on your site so you have this complete copy. I have a co-located server I built myself, so these things are a lot easier for me to accomplish w/o having to worry about ISPs.


And BTW, the ISP I use is an excellent one. Eric Smith at NorthComp.com has a great deal for co-location and for shared servers too, and he'd never have a problem backing up your database for you.

Tags:

2 comments so far...

Re: How to unattach and reattach a database in SQL 2000

Hi, Thanks a lot for your explanation !
I have a question : where can I find the web.config file ?
And is it the same file as in SQL Server 2005?

By rafik on   4/2/2008 4:38 PM

Re: How to unattach and reattach a database in SQL 2000

There's one web.config file for each virtual directory/website(aka web app) (well, actually there's a minimum of one, but it's not a good idea, in general, to have more than one web.config file per web app.

It's located in the 'root' of the web app. To find a web.config file for the web app, go to IIS Adminitrator (Start->Settings->Control Panel->Admin Tools->IIS Administrator), open up the tree to your virtual directory, right click on the web app name, select Properties, then click on the Virtual Directory tab and you'll see the Local Path text box. This is the physical location on your hard disk of the root folder of said web app.

If you're asking questions like this, I highly recommend you purchase a book on ASP.NET 2.0 (or 3.5) Web Application Development. It's much easier to do web development in .NET if you have a basic knowledge of the web.config files *contents*, which is a more involved concept than just its location...

Hope this helps...

By TBBJolietJake on   4/2/2008 4:45 PM

Your name:
Title:
Comment:
Add Comment    Cancel  
  
Blog Archives
  
:: Resources» Fingerfuel Blogs» Andy Hock's Blog
Copyright © 2004-2007 by Fingerfuel.com.