Saturday, 25 July 2015

Attach databases and upgrade to SharePoint Foundation 2010

Attach databases and upgrade to SharePoint Foundation 2010

3 out of 3 rated this helpful - Rate this topic
  Applies to: SharePoint Foundation 2010
Topic Last Modified: 2011-08-05
When you upgrade from Windows SharePoint Services 3.0 to Microsoft SharePoint Foundation 2010 by using the database attach upgrade approach, you upgrade only the content for your environment and not the configuration settings. Using a database attach upgrade approach is useful when you are changing hardware or want to reconfigure your server farm topology as part of the upgrade process. For more information about how to choose an upgrade approach, see Determine upgrade approach (SharePoint Foundation 2010).
The first step in the process is to set up a new environment to host the upgraded content. If you have not yet set up and configured the new environment, follow the steps in Prepare the new SharePoint Foundation 2010 environment for a database attach upgrade to do so. You must create a Web application in the new environment for every Web application in the old environment, copy any server-side customizations, configure services, and apply any farm settings to the new environment.
After you set up the new environment, you can use the procedures in this article to detach and then reconnect the databases to perform the actual upgrade. This article contains the steps required to perform a standard database attach upgrade and a database attach upgrade with read-only databases.
In this article:
noteNote
One frequent cause of failures during upgrade is that the environment is missing customized features, solutions, or other elements. Be sure that any custom elements you have to have are installed on your front-end Web servers before you begin the upgrade process. Use the pre-upgrade checker — and, for a database attach upgrade, also use the test-spcontentdatabase Windows PowerShell cmdlet — to identify any custom elements that your sites might be using. For more information, see Identify and install customizations in the article "Use a trial upgrade to find potential issues."
For more information about the general process of upgrading by using the database attach upgrade approach, see Upgrade process overview (SharePoint Foundation 2010).

Process overview

When you upgrade by using database attach upgrade, you detach the databases in the old farm and then attach them to the new farm. When you attach a database to the new farm, the upgrade process runs and upgrades the whole database. The database attach upgrade process is similar to the in-place upgrade process. The difference is that the database attach upgrade process is performed manually, and is performed in a separate environment.
If you want to preserve your original farm and allow users to continue to access their data, you must set the databases to read-only and then attach a backup copy of the databases.
noteNote
The part of the process in this article that is specific to moving a database from one computer that is running Microsoft SQL Server to a different computer that is running SQL Server is known as planned relocation. For more information about planned relocation, see Moving User Databases (http://go.microsoft.com/fwlink/p/?LinkId=148425).
For a general overview of the upgrade process, see Upgrade process overview (SharePoint Foundation 2010).

Before you begin

Before you begin the database attach upgrade, review the following information about permissions, hardware requirements, and software requirements. Follow the specified steps to install or configure prerequisite software or to modify settings.

Set the previous version databases to be read-only (database attach with read-only databases)

If you are using the read-only databases hybrid approach to upgrade, set the previous version databases to read-only before you back up the databases. In any type of database attach upgrade, you can also set the databases to read-only temporarily to ensure that you capture all the data in the backup so that you are restoring and upgrading the current state of the environment. If the databases are set to read-only, users can continue to view content, but they will be unable to add or change content.
importantImportant
You cannot upgrade a database that is set to read-only. If you are using a database attach with read-only databases, you restore a copy of the database and perform the upgrade on the copy. If you are not using this method, but want to set content databases to read-only temporarily while you back up the current data, make sure that you set the databases to read-write before you attach and upgrade the databases.
importantImportant
Be sure you have run the pre-upgrade checker before you perform this procedure. For more information, see Run the pre-upgrade checker (SharePoint Foundation 2010).
To set a database to read-only in SQL Server 2000
  1. In SQL Server Enterprise Manager, right-click the name of the database that you want to set to read-only, and then click Properties.
  2. In the Properties dialog box, click the Options tab.
  3. Under Access, select the Read-only check box, and then click OK.
To set a database to read-only in SQL Server 2005
  1. In 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 Select a page section, click Options.
  3. In the right pane, under Other options, in the State section, next to Database Read-Only, click the arrow, and then select True.
To set a database to read-only in SQL Server 2008
  1. In SQL Server Management Studio, in Object Explorer, connect to an instance of the Database Engine, expand the server, and then expand Databases.
  2. Select the database that you want to configure to be read-only, right-click the database, and then click Properties.
  3. In the Database Properties dialog box, in the Select a page section, click Options.
  4. In the right pane, under Other options, in the State section, next to Database Read-Only, click the arrow, and then select True.
You can configure the READ_ONLY database availability option by using Transact-SQL. For more information about how to use the SET clause of the ALTER DATABASE statement, see Setting Database Options (http://go.microsoft.com/fwlink/p/?LinkId=148362).

Back up the previous version databases by using SQL Server tools

Follow the appropriate procedure to back up databases in SQL Server 2000, SQL Server 2005, or SQL Server 2008. Repeat these steps for each content database in your server farm.
You do not have to back up the configuration or admin content databases, because you will re-create these databases in the new server farm. For more information about the kinds of databases that you might have in a Windows SharePoint Services 3.0 server farm, see Database types and descriptions (Windows SharePoint Services 3.0).
At the end of this procedure, you will have created duplicates of the read-only content databases.
To back up a database in SQL Server 2000
  1. On the database server, click Start, point to All Programs, point to Microsoft SQL Server, and then click Enterprise Manager.
  2. In SQL Server Enterprise Manager, expand Microsoft SQL Servers.
  3. Expand SQL Server Group.
  4. Expand (local) (Windows NT).
  5. Expand Databases.
  6. Right-click the database that you want to back up, point to All Tasks, and then click Backup Database.
  7. In the SQL Server Backup dialog box, in the Name box, specify a name for the backup, and then in the Backup area, select Database - complete.
  8. In the Destination area, either select an existing destination or do the following:
    1. Click Add.
    2. In the Select Backup Destination box, select File Name, and then next to the File Name box, click Browse.
    3. In the Backup Device Location - (local) dialog box, in the File name box, type a file name, and then click OK.
    4. Click OK again to close the Select Backup Destination dialog box.
  9. Click OK to start the backup process.
  10. Click OK to acknowledge that the backup process is complete.
Repeat the previous procedure to back up all the other content databases that are used by Windows SharePoint Services 3.0 in your environment.
To back up a database in SQL Server 2005
  1. On the database server, click Start, point to All Programs, point to Microsoft SQL Server 2005, and then click SQL Server Management Studio.
  2. In the Connect to Server box, fill in the connection information, and then click Connect.
  3. After you connect to the appropriate instance of the SQL Server 2005 Database Engine, in Object Explorer, expand the server tree by expanding the server name.
  4. 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.
  5. In the Source area, in the Database box, verify the database name.
  6. In the Backup type box, select Full.
  7. Under Backup component, select Database.
  8. In the Backup set area, in the Name text box, either accept the default backup set name that is suggested or type a different name for the backup set.
  9. 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.
  10. Click OK to start the backup process.
Repeat the previous procedure to back up all the other content databases that are used by Windows SharePoint Services 3.0 in your environment.
To back up a database in SQL Server 2008
  1. On the database server, click Start, point to All Programs, point to Microsoft SQL Server 2008, and then click SQL Server Management Studio.
  2. In the Connect to Server box, fill in the connection information, and then click Connect.
  3. After you connect to the appropriate instance of the SQL Server 2008 Database Engine, in Object Explorer, expand the server name.
  4. 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.
  5. In the Source area, in the Database box, verify the database name.
  6. In the Backup type box, select Full.
  7. Under Backup component, select Database.
  8. In the Backup set area, in the Name text box, either accept the default backup set name or type a new name.
  9. 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.
  10. Click OK to start the backup process.
Repeat the previous procedure to back up all the other content databases that are used by Windows SharePoint Services 3.0 in your environment.

Detach the previous version databases (standard database attach)

Before you can attach your databases to the new environment and upgrade the data, you need to detach them from the current environment. After you have detached the databases, you can move them to a new database server or leave them on the existing database server and attach them to the Web applications.
importantImportant
Do not use the following procedure if you are performing a database attach upgrade with read-only databases. To continue to provide your users with access to their content, you need to leave the databases attached, and follow the steps in the Restore a backup copy of the database (database attach with read-only databases) section later in this article to make a copy of the databases instead.
To detach a content database from a Web application
  1. In Central Administration, on the Application Management page, in the SharePoint Web Application Management section, click Content databases.
  2. On the Manage Content Databases page, click the content database you want to detach.
    noteNote
    If the content database does not appear, it might be associated with another Web application. To select another Web application, on the Web Application menu, click Change Web Application.
  3. On the Manage Content Database Settings page, in the Remove Content Database section, select the Remove content database check box, and then click OK.
    noteNote
    Removing the content database does not delete the database; it only removes the association of the database with the Web application.
  4. Repeat steps 2 and 3 for each content database that you want to detach.
You can also use the deletecontentdb Stsadm operation to detach a content database from a Web application. For more information, see Deletecontentdb: Stsadm operation (Windows SharePoint Services).
If you are moving the databases to a different database server, you must also detach the databases from the instance of SQL Server before you move them and attach them to the new instance of SQL Server after you move them.
importantImportant
If you move your databases to a different instance of SQL Server, make sure to verify that security is configured correctly. Check that the accounts you use have the appropriate fixed roles and permissions on the databases, and that they will still be valid accounts if you are moving across domains.
To detach a database from an instance of SQL Server and move it to another instance of SQL Server
  1. In SQL Server 2005 Management Studio, open the source instance of SQL Server, and then expand the Databases node.
  2. Right-click the content database, point to Tasks, and then click Detach. Repeat this step for each content database that you want to detach and move.
    noteNote
    Use this procedure to move only content databases. Do not detach any other databases.
  3. In Windows Explorer, browse to the location of the .mdf and .ldf files for the content databases.
  4. Select the .mdf and .ldf files for the database you want to move and either copy or move them to the destination directory.
  5. In SQL Server 2005 Management Studio, open the source instance of SQL Server.
  6. Right-click the Databases node, point to Tasks, and then click Attach.
  7. In the Attach Database dialog box, browse to the location to which you transferred the .mdf and .ldf files, select the .mdf file for the database you want to attach, and then click OK.
  8. Repeat steps 6 and 7 for each content database that you are moving.

Restore a backup copy of the database (database attach with read-only databases)

After you configure the new server farm, you can restore the backup copies of the databases on one of the following: Microsoft SQL Server 2008 R2, SQL Server 2008 with Service Pack 1 (SP1) and Cumulative Update 2, and SQL Server 2005 with SP3 and Cumulative Update 3. Note that you must restore to a 64-bit version of SQL Server 2008 R2, SQL Server 2008 with SP1 and Cumulative Update 2, and SQL Server 2005 with SP3 and Cumulative Update 3. Start with one database, and then verify that the restoration has worked before you restore the other databases.
The following section provides procedures for restoring the backups.
To restore a backup copy of a database in SQL Server 2005 Enterprise Edition
  1. In SQL Server Management Studio, right-click Databases, and then click Restore Database. The Restore Database dialog box appears.
  2. In the Restore Database dialog box, on the General page, in the To database box, type the name of the database you are restoring.
  3. In the To a point in time text box, keep the default (Most recent possible).
  4. To specify the source and location of the backup sets to restore, click From device, and then click Browse to select the backup file.
  5. In the Specify Backup dialog box, in the Backup media box, make sure that File is selected.
  6. In the Backup location area, click Add.
  7. In the Locate Backup File dialog box, select the file that you want to restore, and then click OK.
  8. In the Select the backup sets to restore grid, select the Restore check box next to the most recent full backup.
  9. In the Restore Database dialog box, on the Options page, under Restore options, select the Overwrite the existing database check box.
  10. Click OK to start the restore process.
To restore a backup copy of a database in SQL Server 2008 Enterprise
  1. After you connect to the appropriate instance of the SQL Server 2008 Database Engine, in Object Explorer, expand the server name.
  2. Right-click Databases, and then click Restore Database. The Restore Database dialog box appears.
  3. In the Restore Database dialog box, on the General page, type the name of the database to be restored in the To database list.
  4. In the To a point in time text box, retain the default (Most recent possible).
  5. To specify the source and location of the backup sets to restore, click From device, and then click Browse to select the backup file.
  6. In the Specify Backup dialog box, in the Backup media box, be sure that File is selected.
  7. In the Backup location area, click Add.
  8. 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.
  9. 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.
  10. In the Restore Database dialog box, on the Options page, under Restore options, select the Overwrite the existing database check box.
  11. Click OK to start the restore process.

Set the databases to read-write (database attach with read-only databases)

You must also set the databases back to read-write before you attach and upgrade them.
To set a database to read-write in SQL Server 2008
  1. In SQL Server Management Studio, in Object Explorer, connect to an instance of the Database Engine, expand the server, and then expand Databases.
  2. Select the database that you want to configure to be read-write, right-click the database, and then click Properties.
  3. In the Database Properties dialog box, in the Select a page section, click Options.
  4. In the right pane, under Other options, in the State section, next to Database Read-Only, click the arrow, and then select False.
To set a database to read-write in SQL Server 2000
  1. In SQL Server Enterprise Manager, right-click the name of the database that you want to set to read-write, and then click Properties.
  2. In the Properties dialog box, click the Options tab.
  3. Under Access, clear the Read-only check box, and then click OK.

Verify custom components

Before you attach the content databases to the Web applications, use the Test-SPContentDatabase Windows PowerShell cmdlet to verify that you have all the custom components that you need for that database.
To verify custom components are available by using Windows PowerShell
  1. Verify that you meet the following minimum requirements: See Add-SPShellAdmin.
  2. On the Start menu, click All Programs.
  3. Click Microsoft SharePoint 2010 Products.
  4. Click SharePoint 2010 Management Shell.
  5. At the Windows PowerShell command prompt, type the following command:
    Test-SPContentDatabase -Name <DatabaseName> -WebApplication <URL>
    
    Where:
    • <DatabaseName> is the name of the database you want to test.
    • <URL> is the URL for the Web application that will host the sites.
For more information, see Test-SPContentDatabase.

Attach a content database to a Web application

When you attach a content database, make sure that the root site for the Web application is included in the first content database that you attach. In other words, before you continue, examine the root of the Web application in the original server farm to determine the first site collection. After you attach the database that contains the root site, you can attach the other content databases for the Web application in any order. You do not have to create any site collections to store the content before you attach the database; this process creates the site collections for you. Make sure that you do not add any new site collections until you have restored all the content databases. When you created the Web applications in the new environment, a content database was created for each Web application by default. You can ignore these default databases until after you have attached your previous version databases, and then you can delete the default databases.
importantImportant
If you are moving the content databases across domains or forests or into another environment that has different service accounts, ensure that the permissions for the service accounts are still correct before you attach the databases.
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. Using the SharePoint Central Administration pages to attach a content database is not supported for upgrading.
Ensure that the account you use to attach the databases is a member of the db_owner fixed database role for the content databases that you want to upgrade.
importantImportant
If you were using forms-based authentication, you will need to configure claims-based authentication for your Web application before you attach any databases. You must also create a policy to grant Full Control to the Web application to the user account that will be performing the database attach upgrade.
For more information, see Configure forms-based authentication for a claims-based Web application (SharePoint Foundation 2010).
tipTip
You cannot attach the same content database more than once to a farm, even on different Web applications. Each site collection in a content database has a GUID that is associated with it, which is registered in the configuration database. Therefore, you cannot add the same site collection twice to the farm, even in separate Web applications. Although you can successfully attach the database in this situation, you will be unable to start the site collection.
If you need a duplicate copy of a site collection in the same farm, first attach the database that contains the site collection to a separate farm, and then use the Stsadm backup and restore operations to copy the site collection over to the other farm. The Stsadm backup and restore process creates a new GUID for the site collection.
To attach a content database to a Web application by using Windows PowerShell
  1. Verify that you meet the following minimum requirements: See Add-SPShellAdmin.
  2. On the Start menu, click All Programs.
  3. Click Microsoft SharePoint 2010 Products.
  4. Click SharePoint 2010 Management Shell.
  5. At the Windows PowerShell command prompt, type the following command:
    Mount-SPContentDatabase -Name <DatabaseName> -DatabaseServer <ServerName> -WebApplication <URL> [-Updateuserexperience]
    
    Where:
    • <DatabaseName> is the name of the database you want to upgrade.
    • <ServerName> is server on which the database is stored.
    • <URL> is the URL for the Web application that will host the sites.
    • Updateuserexperience is the choice to update to the new user experience or stay in the old user experience (part of Visual Upgrade). When you include this parameter, the site is set to preview the new user experience. Omit this parameter if you want the site to remain in the old user experience after upgrade. For more information, see Plan visual upgrade (SharePoint Foundation 2010).
For more information, see Mount-SPContentDatabase.
noteNote
We recommend that you use Windows PowerShell when performing command-line administrative tasks. The Stsadm command-line tool has been deprecated, but is included to support compatibility with previous product versions.
To attach a content database to a Web application by using the Stsadm command-line tool
  1. On the drive on which SharePoint Products and Technologies is installed, change to the following directory: %COMMONPROGRAMFILES%\Microsoft shared\Web server extensions\14\Bin.
  2. Type the following command, and then press ENTER:
    stsadm -o addcontentdb -url <URL> -databasename <DatabaseName>
    [-databaseserver <ServerName>] [-databaseuser <UserName>]
    [-databasepassword <Password>] [-sitewarning <SiteWarningCount>]
    [-preserveolduserexperience true/false]
    [-sitemax <SiteMaxCount>]
    [-assignnewdatabaseid] [-clearchangelog]
    noteNote
    When you set the preserveolduserexperience parameter to true, the sites in the content database keep the look of the previous version after upgrade. When you set this parameter to false, the sites are upgraded to the new look and feel. The default for this parameter is true, which preserves the old look and feel.
    This parameter is part of the Visual Upgrade feature. For more information, see Plan visual upgrade (SharePoint Foundation 2010).
    For more information, see Addcontentdb: Stsadm operation (Windows SharePoint Services).

Verification: Verify upgrade for the first database

After you have attached a database, you can use the Upgrade Status page in Central Administration to check the status of upgrade on your site collections. After the upgrade process is complete, you can review the upgrade log file to see whether there were any issues during upgrade. Also, you can review each upgraded site to find and address any issues with how the content is displayed. For more information, see Verify upgrade and review upgraded sites (SharePoint Foundation 2010).
To view the Upgrade Status page
  • In Central Administration, click Upgrade and Migration, and then click Check upgrade status.
To open the upgrade log file
  • The upgrade error log file and the upgrade log file are located at %COMMONPROGRAMFILES%\Microsoft Shared\web server extensions\14\LOGS. The logs are named in the following format: Upgrade-YYYYMMDD-HHMMSS-SSS-error.log and Upgrade-YYYYMMDD-HHMMSS-SSS.log, where YYYYMMDD is the date and HHMMSS-SSS is the time (hours in 24-hour clock format, minutes, seconds, and milliseconds). An example for an upgrade error log is Upgrade-20090415-132126-374-error.log, and an example for an upgrade log is Upgrade-20090415-132126-374.log.
    noteNote
    The upgrade log file includes the name of the content database being upgraded.

Attach the remaining databases

After you restore the first content database and verify the upgrade by reviewing the upgrade log file, you can continue by restoring and upgrading the next database or databases. You can attach multiple databases at the same time in separate Command Prompt windows to run multiple upgrades at one time. After you successfully restore and upgrade all the content databases, you can review the sites to make sure that they were upgraded correctly.

Verification: Verify upgrade for additional databases

After upgrading any additional databases, view the Upgrade Status page to monitor progress and verify that the upgrade process is complete. Review the log file to identify any other issues, and then review each upgraded site to find and address any issues with how the content is displayed. For more information, see Verify upgrade and review upgraded sites (SharePoint Foundation 2010) and Manage visual upgrade (SharePoint Foundation 2010).

Wednesday, 22 July 2015

MOSS 2007 to SharePoint 2013: Migration using Database Attach Method

MOSS 2007 to SharePoint 2013: Migration using Database Attach Method



In one of my projects, I got a chance to work on the migration where we have migrated contents from MOSS 2007 to SharePoint 2013 environment with the huge content of about 40+ databases and 11000+ sites. We had decided to start the upgrade process using the database attach method as this is the only supported method for upgrading from MOSS 2007 to SharePoint 2013 without much of complications.

Let me tell you, we cannot upgrade the content directly from MOSS 2007 release to SharePoint 2013. The changes between versions are too great, and the hardware requirements differ so much between versions that a direct upgrade is not possible or supported. However, we can perform a series of database-attach upgrades to first upgrade our content to SharePoint 2010 Products and then to SharePoint 2013. The upgrade method is almost similar from MOSS 2007 to SharePoint 2010 and then from SharePoint 2010 to SharePoint 2013.

This blog describes how to perform these sequential database-attach upgrades from MOSS 2007 to SharePoint 2010 and then to SharePoint 2013.

Run preupgradecheck in MOSS 2007 Server
Preupgradecheck will provide us the invaluable information regarding the SharePoint 2007 farm and actions that may be required to be taken prior to upgrading to SharePoint 2010/SharePoint 2013
Run the preupgradecheck as below in command prompt:
stsadm.exe -o preupgradecheck

Once you get “Operation completed successfully”, it will launch the “SharePoint Products and Technologies Pre-Upgrade Check Report”. It can also be located under the following location;
%COMMONPROGRAMFILES%\Microsoft Shared\Web Server Extensions\12\Logs\

Analyze the report and Fix the following settings:
• Identify any third party components used and deploy them to SharePoint 2010 and SharePoint 2013 site. E.g. Nintex, 3rd party features, including web parts, solutions and custom workflows
• Setup Incoming/Outgoing email settings in SharePoint 2010 and SharePoint 2013environment
• Modified Web.Config entries
• Configure Alternate Access Mappings (AAM)
• Find the missing webpart, event receivers or features if any and delete them

Take the Content Database Backup from MOSS 2007
Set the databases to read-only before taking backups.
• On the MOSS 2007’s database server, click Start, point to All Programs, Microsoft SQL Server, and then click SQL Server Management Studio.

SQL-Server-Management-Studio

• Traverse to Databases node by expanding the tree
• Right-click the name of the database that you want to set to read-only, and then click Properties.
• In the Properties dialog box, click the Options tab.
• Under State, select the Database Read-only to True, and then click OK

Backup the database:
Follow these steps to take back-up:
• Traverse to Databases node by expanding the tree.
• Right-click the database you want to back up, point to Tasks, and then click Backup Database

Backup-Database

• In the SQL Server Backup dialog box, specify a name for the backup, select Back-up type – Full, select a destination, and then Click OK to start the backup process.

Restore the Backup on SharePoint 2010 SQL server
• Open the SQL Server Management studio, traverse to “Databases” node. Then right click the “Databases” node and choose “Restore Database…” from the context menu.

Restore-Database

• Specify the Database name, Restore Source, Destination, File names in the screens.
• Click “OK” to start the restore operation and Wait for the restore to complete! The time of restoring database depends upon the database size and server’s capacity.
• Make the Read-Only database to false after restore

Create web application in SharePoint 2010
• In the SharePoint Central Administration, click on “Application Management” and click on “Create or extend Web application” under “SharePoint Web Application Management”.
• Again click on “Create Web application”. Set the settings according to the need.
• Don’t create any site collection.
• Install & Copy the solutions, file system changes (like images, themes) from MOSS 2007 to SharePoint 2010 server.

Remove content database of the newly created web application in SharePoint 2010

Now, we need to delete the content db of the newly created web application in order to avoid any URL conflicts. Run the below stsadm command:
stsadm -o deletecontentdb -url <http://url> -databasename <MOSS2007_Migration_Content>

Attach restored database with the newly created web application in SharePoint 2010
• Test the content database: Before attaching the content databases to the Web applications, use the Test-SPContentDatabase PowerShell cmdlet to verify that all of the custom components that you need for that database. It checks for all artifacts such as feature, setup files, web parts etc. that are referred in the content database are installed in the farm and provide you with a report.
• Test-SPContentDatabase -Name <DatabaseName> -WebApplication <URL>
• Delete the corrupted objects
• stsadm -o databaserepair -url <URL of SharePoint site> -databasename <name of database> -deletecorruption
• Attach the Content DB to Webapplication
• Finally, we need to attach the restored MOSS 2007 database to SharePoint 2010 by running the STSADM command
o The Content DB containing the root site collection is always applied first.
o The other content DBs can be applied in any order. Attach the Content DB of the Root Site collection First. And then Attach the Content DBs of other Site Collections.
stsadm.exe -o addcontentdb -url <URL of SharePoint site> -databasename <MOSS2007_Portal_Content>

• Or you can use the PowerShell cmd-let: Mount-SPContentDatabase
Mount-SPContentDatabase -Name <DatabaseName> – databaseServer <ServerName> -WebApplicationURL

Migrate from Classic Mode to Claims mode
SharePoint 2013 authentication mode is by default Claims mode, so during migration from any previous versions, make sure to migrate authentication from Classic to Claims mode. If the authentication type is Claims already, then ignore this step.

Refer this Tech-net guide on how to migrate to claims – http://technet.microsoft.com/en-us/library/gg251985.aspx

Post Migration fixes
Once the content database attachment process is over, we have to manually fix the below things:
• Migrate any List/Site stp’s present from previous version to next version
• Migrate InfoPath forms and change the url ’s to the new url and then publish forms
• Perform the Visual upgrade to get the look and feel of the next version
o Following are the commands used in PowerShell to do visual upgrade
o SharePoint 2010 visual upgrade using PowerShell

//Use this for entire webapplication
$w = get-spweb http://server/site
$w.webs | ForEach-Object {$_.UIversion = 4; $_.UIVersionConfigurationEnabled = $false; $_.update()}

//Use this for individual site
$web = Get-SPWeb http://server/site
$web.UIVersion = 4
$web.UIVersionConfigurationEnabled = 0
$web.Update()
SharePoint 2013 visual upgrade using PowerShell
Upgrade-SPSite “http://server/site” –VersionUpgrade

Similarly to migrate content from SharePoint 2010 to SharePoint 2013, follow the steps from 1 – 8. Once all the operations are done, browse the migrated site and check the functionality.

Reference:
http://technet.microsoft.com/en-us/library/ee947141(v=office.15)

Migrate from SharePoint 2010 to SharePoint 2013 - Step by Step

Migrate from SharePoint 2010 to SharePoint 2013 - Step by Step

So you are excited by SharePoint 2013's new features and tend to migrate from SharePoint 2010 to SharePoint 2013? Well, this article walks through moving from SharePoint 2010 to SharePoint 2013 step by step, assuming all necessary migration preparations and planning strategies are done, lets move to the core migration process.

Before you start:
  • Change the Authentication to Claims: Claims authentication is the default authentication in SharePoint 2013. Many dependent services (like Office Web Apps) require Claims authentication in SharePoint 2013. So before migration convert your SharePoint 2010 web applications from Classic mode (which is default in SharePoint 2010) to Claims. Technet Reference:http://technet.microsoft.com/library/gg251985 Also, If you have "Forms" authentication, make sure its configured in your target farm before migration. 
  • Cleanup Before Migration - Clean up an environment before an upgrade to SharePoint 2013 - This includes deleting unused sites/site collections, Removing unused features and solutions, Delete orphaned users and sites, Cleanup old document versions, Removing features which are not supported by SharePoint 2013 (such as Web Analytics). Technet Reference: http://technet.microsoft.com/en-us/library/ff382641.aspx
Its recommended that you run database consistency check before taking database backup from SharePoint 2010 farm.

No more In-place upgrade from SharePoint 2010 to SharePoint 2013! In other words - No direct upgrade is possible from SharePoint 2010 to SharePoint 2013. You can't install SharePoint 2013 on top of SharePoint 2010 (as we can install SharePoint 2010 on top of SharePoint 2007) . So only migration is allowed in SharePoint 2013. You can't re-use your existing Hardware for SharePoint 2013 (Also you can't install both SharePoint 2010 and SharePoint 2013 on same machine).

Migration Steps Summary:

  1. Create new SharePoint 2013 Farm, Setup necessary configurations.
  2. Backup - Restore SharePoint 2010 Content Databases to SharePoint 2013's SQL Sever (or perform a detach-attach process)
  3. Verify content databases by running: Test-SPContentDatabase from SharePoint 2013 farm.
  4. Attach Content Databases to SharePoint 2013 web application by running: Mount-SPContentDatabase
  5. Upgrade Site Collections to move them into SharePoint 2013.

Step 1. Create New SharePoint 2013 Farm:
Install and configure new SharePoint 2013 farm. All farm configurations should be setup as in source SharePoint 2010 Farm, including: All necessary configurations like AAM, Email settings, Managed pats, etc. Install any 3rd party software, language packs, custom features and solutions you had in your SharePoint 2010 farm into your new SharePoint 2013 Farm. Create web application(s) to SharePoint 2013 environment as in your existing SharePoint 2010 farm.

As we are going to use the existing content database from SharePoint 2010, Delete the default content database associated with your new web application. If you failed to delete the web application's root site database, you will get "Orphaned Sites" issue on running Test-SPContentDatabase cmdlet as part of migration process. This is because the root site collection exists in both content databases and leads to conflict!
    Alright, This article assumes new SharePoint 2013 Farm is already installed and configured.

    Step 2. Backup - Restore SharePoint 2010 Content Databases to SharePoint 2013 SQL Sever: 
    Backup SharePoint 2010 content databases, Restore them into SharePoint 2013's SQL Server instance.

    Identify and take a list of your source content databases either from Central Administration (Central Administration >> Application Management >> Manage Content Databases )
    get all content databases of a web application
    Or use this PowerShell cmdlet to retrieve all content databases of a particular web application:
    Get-SPContentDatabase -WebApplication "<Web App URL>" | Select Name
    Optionally, you can Setting SharePoint Content databases to read-only before taking backup. But why? because you may want users to continue using SharePoint 2010, same time preventing any data in-consistency on content migrated to SharePoint 2013. To do so: Go to SQL Management Studio >> database properties >> Options >> Set Database Read-only to "True".

    Backup Databases from SharePoint 2010 SQL Server:
    1. Log-in to SQL Server box of your SharePoint 2010 Farm
    2. Open SQL Server Management Studio, Expand Databases node
    3. Right Click your content database, Choose Tasks >> Backupbackup SQL Server database
    4. Set the backup type to "FULL", specify the backup destination and click on "OK" to start backup processbackup SharePoint content database in SQL Server Management Studio
    5. Wait for the backup to complete.SharePoint content database backup
    Repeat this procedure for All content databases of desired SharePoint 2010 web applications.

    Restore Database on SharePoint 2013's SQL box:
    Next step is to Restore all databases taken from SharePoint 2010 to SharePoint 2013 SQL Server.
    1. Copy all required databases backup files to your target SharePoint 2013's SQL Server. 
    2. Open SQL Server Management Studio Right click databases node >>Click Restore DatabaseRestore SQL Server Database
    3. Specify the source as "Device" and Click on the "..." button to add backup files. Click on "Add" button to locate backup files.Restore SharePoint Content Database on SQL Server
    4. Once done, Click on "OK" to return to the restore window.Locate SQL Server backup source
    5. In Destination section , you can type new database name in Database field if you wish to rename your database.Restore SharePoint Databases in SQL Server
    6. Click on "OK" button to start restore process. Wait for the restore successful message.SharePoint Content Database Restore
    7. Once restored, Go to Database properties, Click on Options Tab, Set Database Read-only to False. (If you made it read-only before taking backup!)Set SharePoint Content Database to Read-only

    Step 3. Verify content databases with Test-SPContentDatabase: 
    No more STSADM -o PreUpgradeCheck and its replaced with the PowerShell cmdlet: Test-SPContentDatabase. So we got to execute Test-SPContentDatabase cmdlet which scans content databases of the provided web application and addresses any issues found.

    Syntax:
    Test-SPContentDatabase -Name <Database name> -WebApplication  <Web-App-URL>
    E.g.
    Test-SPContentDatabase -Name "SP2013_Operations_Content" -WebApplication "http://SharePoint13.Crescent.com"
    This would report potential issues such as: Missing Features & Solution dependencies, Orphaned Sites, wide Lists, etc. Resolve Migration issues reported by Test-SPContentDatabase.
    Test-SPContentDatabase Issues

    Test All Content Databases and produce Report
    Lets execute Test-SPContentDatabase for all Content Databases:
    Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue
    
    #Array to hold Content Databases to Test
    $ContentDBS= ("SP2010_IntranetRoot_Content", "SP2010_Sales_content", "SP2010_Operations_Content")
    
    #Web Application to Host
    $WebAppURL = "http://SharePoint13.Crescent.com"
    
    #Loop through each web web application
    Foreach ($DB in $ContentDBS)
     {
         "Checking Content Database - " + $DB | Write-Host -ForegroundColor Green
    
          "Report to Content Database: $($db)" |  Out-File -Encoding default -FilePath $("D:\DBCheck.csv") -Append 
          #Test Content Database and output report to a CSV file
          Test-SPContentDatabase -Name $DB -WebApplication $WebAppURL | ConvertTo-Csv -NoTypeInformation | Out-File -Encoding default -FilePath $("D:\DBCheck.csv") -Append 
    
      }
      
    This script gives nice report in CSV format for easier analysis. To troubleshoot upgrade issues reported, use http://technet.microsoft.com/en-us/library/cc262967.aspx

    Check the upgrade log and deploy any missing components and re-run Test-SPContentDatabase cmdlet to verify again. Make sure UpgradeBlocking is false to move further!

    Step 4. Attach Content Databases to SharePoint 2013 by running: Mount-SPContentDatabase
    After fixing all issues reported by Test-SPContentDatabase, we can start attaching content databases to SharePoint 2013 web application. Remember: Always mount the root site collection's database first! Also, if you migrating My sites, Migrate My Site Host First!

    Mount-SPContentDatabase -name "SP2013_Operations_Content" -DatabaseServer "G1-SP2013-DB01.Crescent.com" -WebApplication "http://sp13.crescent.com" -confirm:$false
    Once mounted the content database to web application successfully, The site collection is accessible in SharePoint 2010 Mode!

    Step 5. Upgrade Site Collections to move them into SharePoint 2013.
    One more step to complete our migration: Upgrading site collections.
    By default, after migrating from SharePoint 2010 to SharePoint 2013, All migrated site collections will be on SharePoint 2010 format, retaining its old look and feel and other functionalities. We've to explicitly migrate all site collections to SharePoint 2013.

    This can be done by Site collection administrators by clicking links from upgrade reminder banner.

    At Site Collection Level, you can make use of Site Collection Health Checkup:
    New in SharePoint 2013, Site collection Administrators can perform health checkup at site collection level before upgrading site collections from SharePoint 2010 mode to SharePoint 2013! Navigate to
    • Site Settings >> Site Collection Administration 
    • Click on Site collection health checks (Or use PowerShell Test-SPSite -identity <URL>)
    Site collection health checkup report gives customized files, missing galleries, missing Content Types, content type conflicts, missing site templates, unsupported language packs, etc. You can repair some of the issues by running: Repair-SPSite -identity <URL>
    Site collection Health Checkup

    Deferred site collection upgrade - Its a replacement for Visual Upgrade feature (Once site collection is upgraded, can't be rolled back). SharePoint 2013 shipped with files to Support SharePoint 2010. Not just user interface but actual SharePoint functionality itself. E.g. You can find 14 folder on SharePoint 2013 installation. So all files will still be maintained. E.g. Features, Event Receivers, Solutions can be deployed on 14 hive, etc. So, almost all of your existing SharePoint 2010 customizations should just work fine.

    You will see a banner on top of Site collections now!

    To upgrade the site collections: Click on "Start now" link on the banner (You can get there by going to Site Settings >> Site Collection Upgrade as well.)
    Upgrade SharePoint 2010 Site CollectionsConfirm the site collection Upgrade

    We can monitor the upgrade progress with SiteUpgrade.aspx page, which provides a link to an upgrade log for troubleshooting purposes. From here, you can either start the actual upgrade or create a preview site.
    Monitor Upgrade Status
    SharePoint Farm Administrators can do it through bulk through PowerShell script:
    Upgrade-SPSite -identity "http://sharepointsite" -VersionUpgrade

    We can upgrade all site collections under the specific web application with PowerShell cmdlet:
    #To upgrade all site collections in a Content Database
    Get-SPSite -contentdatabase <content database name> -limit All | Upgrade-SPSite -versionUpgrade 

    Once upgrade completed successfully, Verify Your site collection is with all new SharePoint 2013 features.
    SharePoint 2013 Upgrade Progress

    Get Upgrade Status:
    Upgrade can be time consuming where there is a large number of site collections exists on the given content database. Get the Status of  upgrade from "Upgrade Status" page in central administration page (Central Admin >> Upgrade and Migration >> Check upgrade status )!

    Or use the PowerShell script: 
    Get-SPSiteUpgradeSessionInfo -contentdatabase "<Content DB Name>" -showInProgress -showCompleted -ShowFailed 
    Sites will be in locked state until upgrade completed.

    That's all, We are completed now! As a best practice, Review event logs and ULS logs after migration completed successfully!!

    Here is our SharePoint 2010 site:
    sharepoint 2010 to sharepoint 2013 migration
    Here is the SharePoint 2010 site migrated with SharePoint 2013:
    sharepoint 2010 to sharepoint 2013 upgrade
    The Final site after site collection upgrade:

    Additional Things to Consider:

    You can try the Demo Upgrade with Evaluation Site Collection:
    Demo upgrade allows to get the SharePoint 2013 preview of existing site collection by making a copy. You can try it by clicking "Try a Demo Upgrade" link either from "Upgrade Reminder banner " or by going to
    • Site Settings >> Site Collection Admin 
    • Site collection upgrade, click on Try a demo upgrade
    • Site collection admin receives an email when timer job “Create upgrade Evaluation Site Collections” creates a site collection
    Farm administrators can request an Evaluation Site Collection using PowerShell:
    Request-SPUpgradeEvaluationSite -identity <Site Collection URL>

    This Provisions a temporary site collection with SharePoint 2013's look and feel to validate your site collection to get the preview of your site collection on SharePoint 2013. Remember, the evaluation site collection expires after 30 days, and gets auto deleted!
    sharepoint 2010 to sharepoint 2013 migration step by step
    Remember, while upgrading: you can't downgrade! Meaning, you can't upgrade from SharePoint Server to SharePoint Foundation or You can't upgrade from SharePoint Server Enterprise to Standard version!

    Disable Self Service Upgrade
    In some cases, you may want to disable self service upgrade on specific site collections, for e.g. You may want to disable upgrade on heavily customized site collections. We can disable upgrade which hides the "upgrade Reminder" bar at the top of the site collection eventually.

    #Get the site collection
    $Site = Get-spsite "http://Intranet2013.crescent.com/sites/operations"
    #Disable Upgrade options from UI
    $Site.AllowSelfServiceUpgrade = $false

    This disables upgrade options from site the collection by removing the upgrade banner and the "Upgrade Site Collection" button from Site collection upgrade page of site settings. So now, the only option to upgrade is: using PowerShell cmdlet: Upgrade-SPSite

    What about Migrating Service Applications?
    Just because you can migrate service applications, doesn't mean you must! Consider upgrading service applications from SharePoint 2010 to SharePoint 2013 when you have some critical data in it and it involves lot of time to re-do!! I'm keeping it aside for now, will cover this in an another article.

    Upgrade from SharePoint 2007 to SharePoint 2013
    Want to migrate from MOSS 2007 to SharePoint 2013? Sure, But there is no way to migrate from SharePoint 2007 to SharePoint 2013 directly! We've to Migrate from MOSS 2007 to SharePoint 2010 first (can use Staging environment for this!) and then perform SharePoint 2010 to SharePoint 2013 migration again (Or you can use 3rd party migration tools to upgrade from SharePoint 2007 to SharePoint 2013 directly) Read my related posts:

    References:
    I would strongly recommend to go through these excellent technet resources:


    Read more: http://www.sharepointdiary.com/2013/09/migrate-from-sharepoint-2010-to-2013-step-by-step.html#ixzz3gfr1TUex