One of my most recent projects was the migration of our intranet from SharePoint 2007 to 2010. Since we were going to change the name of the site, I was able to run through this “script” several times as practice to make sure I had everything correct.
I decided to do a detach and attach method. Here are some of the things we did.
- We preformed several test a detach and attach upgrades with the new URL. This allowed us to test everything using the new url, and make changes back in the original 2007 site so that it would work once we performed the final live cutover.
- All new code/pages/hacks were added to the 2010 site into New documents libraries. These were backed up using this script and restored after every new test detach an attach test. This way all new code would be in place with the final live cutover.
- Since we were doing a new Navigation, we created the navigation in the old 2007 site, and hid them by audience. Then one of the steps below is to change the audience which would un-hide the new navigation in the final cutover.
Step 1. Backup all the new code/pages/hacks that have been added to the new site that needs to be restored.
$folderDate=$(get-date -uformat "%Y-%m-%d") $folderHour=$(get-date -uformat "%H") $backupDir="\\Path\To\Backup\$folderDate\$folderHour" foreach ($web in $(Get-SPSite | Get-SPWeb)){ foreach ($list in $web.Lists) { mkdir -force "$backupDir\$($Web.Title.replace(' ','').replace('/','-'))\" Export-SPWeb $($web.Url) -itemurl "$($list.RootFolder.ServerRelativeUrl)" -path "$backupDir\$($Web.Title.replace(' ','').replace('/','-'))\$($list.Title.replace(' ','').replace('/','-')).cmp" } }
Now we have captured all the changes that were made to the new site (which we will be restoring after the next cutover test)
Step 2. Remove the previous test cutover site
Remove-SPWebApplication "SharePoint - intranet.company.com80" -RemoveContentDatabases -DeleteIISSite
Step 3. Re-create new app and apppool.
New-SPWebApplication -Name "SharePoint - intranet.company.com80" -Port 80 -HostHeader intranet.company.com -URL "http://intranet.company.com" -ApplicationPool "SharePoint - intranet.company.com80"
Step 4. remove the content database that is created by default
Get-SPContentDatabase -WebApplication "SharePoint - intranet.company.com80" | Remove-SPContentDatabase
Step 5. Backup 2007 site to a share and restore to new SQL server (or new db name on existing SQL server).
Backup:
$SRCSQLSERVER='OldSQLServer' $DESTSQLSERVER='NewSQLServer' $sqlcmdBackup="BACKUP DATABASE [Content_Intranet] TO DISK = N'\\path\to\network\share\Content_Intranet.bak' WITH NOFORMAT, NOINIT, NAME = N'Content_Intranet FullBackup', SKIP, NOREWIND, NOUNLOAD, STATS = 10" invoke-sqlcmd -query "$sqlcmdBackup" -Server $SRCSQLSERVER -QueryTimeout 1200
Restore:
$sqlcmdRestore="RESTORE DATABASE [Content_Intranet] FROM DISK = N'\\path\to\network\share\Content_Intranet.bak' WITH FILE = 1, MOVE N'Content_Intranet' TO N'K:\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\Content_Intranet.mdf', MOVE N'Content_Intranet_log' TO N'K:\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\Content_Intranet_log.LDF', NOUNLOAD, REPLACE, STATS = 10" invoke-sqlcmd -query "$sqlcmdRestore" -Server $DESTSQLSERVER -QueryTimeout 1200
Step 6. Mount the restored database and upgrade the uner experience.
Mount-SPContentDatabase -Name Content_Intranet -DatabaseServer NewSQLServer -WebApplication http://intranet.company.com -Updateuserexperience
Step 7. Re-import exported Document Libraries that contain the new code/pages/apps
Import-SPWeb http://intranet.company.com -Path \\path\to\network\share\date\hour\LibraryName.cmp
Step 8. Clean up navigation by changing audience, change homepage to new page in restored Document Libraries.
Step 9. Alter web.config for Cisco WebVPN
Step 9. Allow inline PDFs
That was it. I did it several times, and it ended up being a smooth cutover.
Comments are closed.