$originalURL = Read-Host "Location of the original site collection:" $newURL = Read-Host "Location to move the site collection to:" $backupLocation = Read-Host "Location of the backup file:" Backup-SPSite $originalURL -Path $backupLocation -force #You may like to confirm the integrity of the backup before running this step... Remove-SPSite -Identity $originalURL -Confirm:$false Restore-SPSite -Identity $newURL -Path $backupLocation -force -Confirm:$false Remove-Item $backupLocation
Thursday, 10 April 2014
Moving SharePoint Site Collection
The following power shell script can be used to move a site collection from one location to another. It basically takes a backup and restores it in another location. I have used this in the past to archive sites to a /archive managed path.
Tuesday, 8 April 2014
Re-building your SharePoint 2010 site from production without solution source
At times clients have requested that their test sites be restored from production as they have not been maintained or used for staging solution upgrades. This is fine if you have the source code to all the required solutions from the site etc. What if there is no formal source control and previous developers have left the organisation?
The following is a list of tasks to re-build a test site from production without access to deployed solutions and other resources.
If you have an existing version of the site you are trying to restore you will first need to delete the existing site collection before restoring the production version. You can achieve this through SharePoint Central Admin -> Manage Application -> deleted site collection.
NOTE: After deleting the site and attempting to restore the prod version again you may encounter the following error:
Restore-SPSite : The operation that you are attempting to perform cannot be completed successfully. No content databases in the web application were available to store your site collection. The existing content databases may have reached the maximum number of site collections, or be set to read-only, or be offline, or may already contain a copy of this site collection. Create another content database for the Web application and then try the operation again.
To resolve this issue I came across a blog by kancharla srikanth. Who outlines the following steps:
1) Run the following PS Scripts:
Done.
The following is a list of tasks to re-build a test site from production without access to deployed solutions and other resources.
Step 1:
You will need to retrieve any solutions used by the site. Once you know the solution name you can use the following ps script to extract the .wsp from the production farm. NOTE: I found this script posted on Kirk Evans blog here.$farm = Get-SPFarm
$file = $farm.Solutions.Item('YourSolutionName.wsp').SolutionFile
$file.SaveAs('c:\temp\YourSolutionName.wsp')
Step 2:
In the past I have also noticed developers will update files contained in solutions directly in the 14 hive without actually updating the solutions themselves and re-deploying. So to be sure you have the updated feature files and any other files deployed by the solution you should inspect the the manifest.xml file within the solution. Re-naming the .wsp to .cab will give you access to the manifest file, which will indicate which files are deployed by the solution. You can compare the solution versions from within the .cab folder with those in the 14 hive to ensure your solution is up to date.Step 3:
Make a backup of the site collection from production.backup-spsite -identity "YouSiteCollectionUrlHere" -Path "locationOfBackup"
Step 4
Restore your site onto your test environment.restore-spsite -identity "YouSiteCollectionUrlHere" -Path "locationOfBackup"
If you have an existing version of the site you are trying to restore you will first need to delete the existing site collection before restoring the production version. You can achieve this through SharePoint Central Admin -> Manage Application -> deleted site collection.
NOTE: After deleting the site and attempting to restore the prod version again you may encounter the following error:
Restore-SPSite : The operation that you are attempting to perform cannot be completed successfully. No content databases in the web application were available to store your site collection. The existing content databases may have reached the maximum number of site collections, or be set to read-only, or be offline, or may already contain a copy of this site collection. Create another content database for the Web application and then try the operation again.
To resolve this issue I came across a blog by kancharla srikanth. Who outlines the following steps:
1) Run the following PS Scripts:
Get-SPDeletedSiteThis will return the site ID of any site which has been set for deletion but not yet deleted by the "Gradual Site Delete Job".
Remove-SPDeletedSite -identity "SiteIdObtainedAbove"2) Manually run the "Gradual Site Delete job" for the given web application via Central Admin -> Monitoring -> Job Definitions
Step 5
Deploy the solution .wsp obtained in Task 1 making sure all solution files match the 14 hive versions.Done.
Subscribe to:
Comments (Atom)