I was asked to make a copy of a Site Collection on the production server and put it on the development server with the subsites and permissions intact. These steps did the trick using these scripts (thanks to Brad Schacht’s Blog for this):
Backup-SPSite -Identity SiteCollectionURLHere -Path BackupFilePathHere [-Force] [-NoSiteLock] [-UseSqlSnapshot] [-Verbose]
- Force – Include this if you want to override a backup with the same name
- NoSiteLock – Will prevent the site from going to Read Only mode while the backup is being taken. A small warning, if someone changes content on the site while the backup is being created and according to Microsoft “might lead to possible data corruption”
- UseSQLSnapshot – A database snapshot will be taken before the backup begins and the backup will be done off the snapshot. The advantage is that changes can be made to the site while the backup process is running without fear of corruption. The snapshot will be deleted automatically when the backup is completed. You don’t need to specify the -NoSiteLock parameter when using this method
Restore-SPSite -Identity SiteCollectionURLHere -Path BackupFilePathHere [-DatabaseServer DatabaseServerNameHere] [-DatabaseName ContentDatabaseNameHere] [-HostHeader HostHeaderHere] [-Force] [-GradualDelete] [-Verbose]
- DatabaseServer – Specify the server for the content database
- DatabaseName – Specify the name of the content database
- HostHeader – URL of the Web application that will hold the host-named site collection
- Force – Overwrite the site collection if it exists
- GradualDelete – Recommended for site collections over 1 Gig in size, existing data is marked as deleted and gradually removed over time by a job rather than all at once to reduce the performance hit of deleting large amounts of data
—————————————————————————–
- To Backup site
- Use Remote Desktop to log into production server
- Login with the Service Account (farm admin account that has access to content databases)
- Create a folder on the e: drive to put backup file
- (Note: it is best practice not to put backup files on the c: drive)
- Open ‘SharePoint 2010 Management Shell’
- Create backup script in Notepad, then copy and paste it in:
- Use Remote Desktop to log into production server
Backup-SPSite -Identity http://yourProductionServer/sites/yourSite
-Path e:\SiteBackups\yourSite.bak
——————————————————————————————
- To Restore site
- Use Remote Desktop to log into development server
- Login with the Service Account (farm admin account that has access to content databases)
- Create a folder on the e: drive to put backup file
- Copy and paste .bak file from production server Remote Desktop window (e: drive) to development server Remote Desktop window (e: drive)
- Open ‘SharePoint 2010 Management Shell’
- Create restore script in Notepad, then copy and paste it in:
- Use Remote Desktop to log into development server
Restore-SPSite “http://yourDevServer/sites/yourSite”
-Path e:\SiteBackups\yourSite.bak
—————————————————————————–
Note 1: it is best practice to run Backup and Restore scripts after hours because of the site logs, and because the site will be locked (read only) during the backup. Although there are some alternatives available, such as the [-UseSqlSnapshot] and [-NoSiteLock] paramaeters…
Backup-SPSite -Identity SiteCollectionURLHere -Path BackupFilePathHere [-Force] [-NoSiteLock] [-UseSqlSnapshot] [-Verbose]
See the Backup-SPSite technet page for details on these parameters.
Note 2: The difference between Backup-SPSite and Export-SPWeb
- Workflows are included when you use the Backup_SPSite cmdlet
- SPSite targets Site Collection objects
- SPWeb targets sites (subsites), list and library objects