Saturday, September 8, 2012

Restore Web Application from a Database File (*.mfd) in SharePoint 2010


You discover your server is down and there is no way to start it. You think the OS has problems or the hard disk is a disaster and has some bad sectors. Unfortunately, the server is never restarted again, but the data is able to be recovered and restored along with a lot of files from your hard disk. The challenge is to think about the way to restore your web application from the database file (*.mdf). In this article, I will show the easy way to restore the web application from the *.mdf file with the same information as your old system environment, securities and other things.
I don’t remember the exacy old environment such as the network topology, the farm configuration, the security for each department, group permission…thus, I only can setup the new server as similarly as possible. And now I have the database file from web application at port 80, named “WSS_Content.mdf”, the content looks like this:
2012-09-05-RestoreWebApp-01.png
There are some sub-sites for department and a lot of documents, folders and other resources and I need to restore all of them. Here is the step by step that I did to recover my data, that’s so easy.
Step 1: Copy *.mdf to Data folder of SQL Server
2012-09-05-RestoreWebApp-02.png
Open SQL Studio Management and connect to your SQL Server for SharePoint, then attach the database file.
2012-09-05-RestoreWebApp-03.png
Step 2: Address to your Central Administration and create the new web application with 1 site collection. You can create the new web app without the same information as the old environment, as it’s not required. In this example, I’ve created the new web app at port 8087 and the server name is also completely different from the old version.
Click on Application Management on the left navigation, then click on the Manage content databases on the right pane.
2012-09-05-RestoreWebApp-04.png
The new page is opened and you can select the web app to be restored. In my example, I’ve worked on port 8087
2012-09-05-RestoreWebApp-05.png
Next click on the link of this content database associated to web application, you will see this:
2012-09-05-RestoreWebApp-06.png
Forget other information, just focus on the option named “Remove content database” and check this option. You will get the popup to confirm that this option should be checked, the content database of this web application will be deleted after you click OK which is fine. That’s my goal.
Step 3: Run SharePoint PowerShell, and type the command

1New-SPContentDatabase -Name <ContentDbName> -WebApplication <WebApplicationName>

Where <ContentDbName> is the name of the content database to create and <WebApplicationName> is the name of the Web application to which the new database is attached.
In my example:
New-SPContentDatabase –Name WSS_Content –WebApplication http://laptop-hai
2012-09-05-RestoreWebApp-07.png
That’s all; see the result:
2012-09-05-RestoreWebApp-08.png
My purpose is to restore all files and folders from the old system. I can now work as I did on the old system and never worry about disaster and recovery data. If you run into the same problem, just follow these steps and enjoy the result. Good luck.
You can read more about the solution here.

No comments: