Search This Blog

Sunday, February 1, 2015

Sharepoint Migration

::*********************************************************************************** 


:: Backing up and restoring a web (subsite) in any top level site 

::*********************************************************************************** 
Backs up or restores a SharePoint Web site.
Usage (backup): smigrate -w -f [-e] [-y]

Usage (restore):
smigrate -r -w -f [-x]

Operations and Parameters:
-f Backup filename - required. Specify a filename with the extension .fwp.
-e Exclude subsites during backup - optional. No parameters.
-r Restore - optional. No parameters.
-w Website URL - required. Valid URL to a SharePoint Web site.
-x Exclude security during restore - optional. No parameters.
-y Confirm that you want to overwrite an existing backup file.
-u Administrator username.
-pw Administrator password.
Specify * as the password to be prompted for a password.

Example backup:
smigrate -w http://server -f backup.fwp
smigrate -w http://server -f c:\backups\backup.fwp
smigrate -w http://server -f \\share\folder\backup.fwp
smigrate -w http://server -f c:\backups\backup.fwp -e -y

Example restore:
smigrate -r -w http://server -f backup.fwp
smigrate -r -w http://server -f c:\backups\backup.fwp
smigrate -r -w http://server -f \\share\folder\backup.fwp
smigrate -r -w http://server -f c:\backups\backup.fwp -x
****************************************************************************************************

::***********************************************************************************************
:: Backing up a 
top-level site to a file
::***********************************************************************************************::
echo %0 STARTING on %COMPUTERNAME%.. > %0.log
echo. | date | find /I "current" >> %0.log
echo. | time | find /I "current" >> %0.log
echo. >> %0.log
set LOC=C:\Program Files\Common Files\Microsoft Shared\Web server extensions\60\Bin
set DRV=E
::
:: NOTE: Has to run as service account else STSADM fails with:
:: Cannot connect to the configuration database.
::***********************************************************************************************
set SITE=BizProcesses
echo %0 : backup of site '%SITE%' >> %0.log
::
if exist E:\backup goto DRIVEE
echo E:\backup does NOT exist, so we'll try writing to D:\backup. >> %0.log
set DRV=D
goto RUNIT
::--------------------------------------------------
:DRIVEE
echo E:\backup exists, so we'll write %SITE%.dat there. >> %0.log
::--------------------------------------------------
:RUNIT
"%LOC%"\stsadm -o backup -url 
"http://%COMPUTERNAME%/sites/%SITE%" -filename "%DRV%:\backup\%SITE%.dat" -overwrite >> %0.log
::
::
echo. >> %0.log
echo %0 ENDING. >> %0.log
echo. | time | find /I "current" >> %0.log
::************************************************************************************************
::***********************************************************************************************
:: Restoring a site collection from backup
::***********************************************************************************************

:: Restore.bat - restore /sites/.. from backup
::
echo %0 STARTING on %COMPUTERNAME%.. > %0.log
echo. | date | find /I "current" >> %0.log
echo. | time | find /I "current" >> %0.log
echo. >> %0.log
set LOC=C:\Program Files\Common Files\Microsoft Shared\web server extensions\60\Bin
set DRV=E
::
:: NOTE: Has to run as service account else STSADM fails with:
:: Cannot connect to the configuration database.
::
::
::***********************************************************************************************************
set SITE=BizProcesses
::
::
echo %0 : STSADM restore site '%SITE%'. >> %0.log
::
if exist E:\backup goto DRIVEE
echo E:\backup does NOT exist, so we'll read from D:\backup. >> %0.log
set DRV=D
goto RUNIT
::--------------------------------------------------
:DRIVEE
echo E:\backup exists, so we'll read %SITE%.dat from there. >> %0.log
::--------------------------------------------------
:RUNIT
"%LOC%"\stsadm -o restore -
url "http://%COMPUTERNAME%/sites/%SITE%" -f "%DRV%:\backup\%SITE%.dat" -overwrite >> %0.log
::
::"%LOC%"\stsadm -o restore 
-url "http://%COMPUTERNAME%/sites/%SITE%" -f "W:\%SITE%.dat" -overwrite >> %0.log
::
echo. >> %0.log
echo %0 ENDING. >> %0.log
echo. | time | find /I "current" >> %0.log
::***********************************************************************************************************


::************************************************************************************************************
Database attach migration from Sharepoint server 2003 to MOSS
::************************************************************************************************************

Migrating from SPS2003 to SharePoint 2007 on Database attachment method involves the below 4 tasks.

Run PreScan.exe in SPS 2003 server.
Take the back up of content database of SharePoint Portal Server 2003.
Restore the content databases back up on SQL Server of MOSS 2007.
Create web application in MOSS 2007.
Attach the SPS 2003 databases to MOSS 2007.

Run Prescan.exe in SPS 2003 Server
Download & Run the prescan.exe as below in command prompt:
prescan.exe /c preupgradescanconfig.xml /all
Download URL: http://www.microsoft.com/download/en/details.aspx?DisplayLang=en&id=22806

Backup Databas in sql Server
1. In Microsoft SQL Server Management Studio, right-click the name of the database that you want to 
set to read-only, and then click Properties.
2. In the left pane, click Options.
3. In the right pane, under Other options, under State, next to Database Read-Only, click the down
 arrow, and then select True.


Restore back up on SQL Server attached with MOSS 2007:
The first step in restoring database is to create a database in SQL Server 2005. Let the newly created 
database name is “Portal_Site_Restore”.

1. Expand Database “Portal_Site_Restore”, right-click the database you want to restore, point to Tasks, 
point to Restore, and then click Database. The Restore Database dialog box appears.
2. On the General page, the name of the restoring database appears in the To database list box.
3. In the To a point in time text box (if using SQL Server 2005 Enterprise Edition), retain the default 
(Most recent possible).
4. To specify the source and location of the backup sets to restore, click From device, and then 
specify the database backup path (in our case, it is “Portal_Site.bak”) in the list box.
5. In the Select the backup sets to restore grid, select the backup path.
6. From the options tab, select “overwrite existing database”.
7. Specify the paths for .ldf and .mdf in the options tab.
8. Click OK to start the restore process.

Create website in IIS

Run command in PS or in command tool
stsadm.exe -o addcontentdb -url http://servername:1234 –databasename Portal_Site_Restore
stsadm.exe -o addcontentdb
-url 
-databasename 
[-databaseserver ]
[-databaseuser ]
[-databasepassword ]
[-sitewarning ]
[-sitemax ]
::**********************************************************************************************************
Database attach migration from Sharepoint server 2007(MOSS) to Sharepoint Enterprise 2010
::**********************************************************************************************************


A. Run prechecker

B. Backup Database
On the database server, click Start, point to All Programs, point to Microsoft SQL Server 2008, and then
 click SQL Server Management Studio.
In the Connect to Server box, fill in the connection information, and then click Connect.
After you connect to the appropriate instance of the SQL Server 2008 Database Engine, in Object
 Explorer, expand the server name.
Expand Databases, right-click the database that you want to back up, point to Tasks, and then click
 Back Up. The Back Up Database dialog box appears.
In the Source area, in the Database box, verify the database name.
In the Backup type box, select Full.
Under Backup component, select Database.
In the Backup set area, in the Name text box, either accept the default backup set name or type a new 
name.
In the Destination area, specify the type of backup destination by selecting Disk or Tape, and then 
specify a destination. To create a different destination, click Add.
Click OK to start the backup process.

C. To restore a backup copy of a database in SQL Server

After you connect to the appropriate instance of the SQL Server 2008 Database Engine, in Object
 Explorer, expand the server name.
Right-click Databases, and then click Restore Database. The Restore Database dialog box appears.
In the Restore Database dialog box, on the General page, type the name of the database to be 
restored in the To database list.
In the To a point in time text box, retain the default (Most recent possible).
To specify the source and location of the backup sets to restore, click From device, and then click
 Browse to select the backup file.
In the Specify Backup dialog box, in the Backup media box, be sure that File is selected.
In the Backup location area, click Add.
In the Locate Backup File dialog box, select the file that you want to restore, click OK, and then, 
in the Specify Backup dialog box, click OK.
In the Restore Database dialog box, under Select the backup sets to restore grid, select the Restore
 check box next to the most recent full backup.
In the Restore Database dialog box, on the Options page, under Restore options, select the Overwrite
 the existing database check box.
Click OK to start the restore process.


D. Create Website in IIS

E. You can use either the Mount-SPContentDatabase cmdlet in Windows PowerShell or the
 addcontentdb Stsadm command to attach a content database to a Web application.

Mount-SPContentDatabase -Name -DatabaseServer -WebApplication [-Updateuserexperience]
is the name of the database you want to upgrade.
is server on which the database is stored.
is the URL for the Web application that will host the sites.

::***********************************************************************************

Database attach migration from Sharepoint On Premises to Sharepoint Online
::************************************************************************************

We need to use tool to achive this. 

Best tools available are metalogix Migration Manager for SharePoint and Quest ->
 Migration-Manager-for-SharePoint.
Personally I found Quest tool better than Metalogix

No comments:

Post a Comment