Monday, November 24, 2008

Backup / Restoring SharePoint 2007 Site from SQL Database

I got this excellent article on SharePointdogs for backup / restoring the SharePoint site from SQL DB :

Here is one of defined approach which worked wonders for me :

Using SQL, Backup the SQL Content Databases which are required and Restore them to a new databases in the SQL and attach these databases to the new application.
(Briefly we can say that take your content db ‘Offline’ using the Central admin. Take the content database offline in SQL Studio (Take Offline context menu item). Copy your database mdf and ldf files to the new machine (the destination machine). Attach the copies on the new SQL server using SQL Studio. Add the copied content DB to the Web Application on the new machine using the Central Admin on the new web server.)
1)Find the content Database
These are listed under Central Admin->Application Management->Site Collection List
2) Backup the content database
You could alternatively detach it, and copy it. Just doing a backup in SQL Server 2005 Management studio is easier.
3) Restore content database to new server
Copy the BAK file to new server. Create an empty DB in Management Studio, restore from backup, you may need to change an option in the “options” tabof the restore dialog to get it to work. (Overwrite db).
4) Create Web App on new Server
Central Admin->Application Management->Create or extend Web App->Create New Web App.
5) Associate restored DB with new Web App
Central Admin->Application Management->
SharePoint Web Application Management->Content Databases->
Remove Content Database from your new web app.
Now use STSADM to add restored DB to this web app
c:\program files\common files\microsoft shared\web server extentions\12\bin on new server is where you can find the STSADM.
run this command from there.
stsadm -o addcontentdb -url http://yourwebapp:port -databasename yourcontentdb -databaseserver yoursqlserver
6) Run ISSRESET from command prompt.


Anonymous said...

i tried for mysite content DB restore but mysite content DB was restore successfully but somehow some of mysites are missing. any suggestions?

Payal Vyas said...

Even could successfully restore content DB, create a new web application, remove its DB and attached the restored DB. However the site is missing.

Anonymous said...

Step 6: Run IISRESET, not ISSRESET. Typo

Lerato said...

Hi, please bear with me as I'm still new to SP. I get this when I run the command:

"The attach operation cannot continue because another object in this farm already contains the same ID. Each object in a farm must have a unique ID. In order to proceed with the attach operation you must assign a new ID to this database. To attach this database with a new ID, use the "stsadm.exe -o addcontentdb" operation with the -assignnewdatabaseid parameter. Note that if this new database and an existing database contain the same site collections, attaching this database will likely result in orphaned site collections due to conflicts between the two databases.". It is refering to the restored database that I want to associate with my new web app. Please help.

Tyler Holmes said...

Worked like a charm for me (regular content database). Thanks!

Anonymous said...

Nice Article works like a dream !. Always remember if there is other code deployed or web.config changes these also may need restoring.

SharePoint Server Recovery said...

After reading this post, it seems that this backup/ restoring method is much easier than other one Central Administration, Stsadm.exe. I will also check this method & let you know if I found any problem!! Thanks :)..

Dominique said...


I tried:
stsadm -o addcontentdb -url http://yourwebapp:port -databasename yourcontentdb -databaseserver yoursqlserver

but when I run it I have an error:
c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN>stsa
dm -o addcontentdb -url -databasename WSS_window
s7_content -databaseserver VOTSPRSTR2\MSSQLSERVER

The server instance specified was not found. Please specify the server's addres
s and port.
Any idea?

Gray Failures: What is it and how to detect one?

If you are reading this article , i guess you are curious to know about gray failures and different methods to detect gray failures.  Hopefu...