2

We are trying to copy a SP 2010 site collection from our prod environment to dev. The site collection has it's own content db.

Is it possible to just make a backup of the prod content db, restore it to dev, and create a new site collection using existing db?

If so, what is the process or powershell commands?

Thanks.

3

If your production and development environment is patched to the same version, you can just go to sql management studio and take a backup of the content database, move it the dev environment and restore it using sql management studio, and then use Powershell to mount it to a web application ( Use Test-Spcontentdatabase before this step ):

Use the Test-SPContentDatabase cmdlet to test a content database against a Web application to verify all customizations referenced within the content database are also installed in the web application.

test-spcontentdatabase -name wss_content_productionCopy -webapplication http://Devwebapplication

And if there are no errors, use the mount cmdlet to mount the database to a web application:

mount-spcontentdatabase -name wss_content_productionCopy -webapplication http://DevWebapplication

Then just change the site collection administrator from central admin to the ones you use in the dev environment.

After you have successfully mounted the database, maybe you want all your content to be in one place, so if you like to move the site collection from your production database to the dev environment database, you can then use:

move-spsite http://DewWebapplication/sites/sitename -destinationdatabase wss_content_dev

Mount-SpContentDatabase

Test-SpContentDatabase

Move-SpSite

Best of luck!

  • Move-spsite will not work between two farms. – Waqas Sarwar MVP Sep 3 '14 at 21:50
  • Updated my answer so there are no misunderstandings about what the cmdlet does. – Christoffer Sep 4 '14 at 4:40
  • Looks like you got the same site in 2 databases connected to a single web application OR deleted a site but not removed it correctly. Deleting on of them may solve it. I'm not saying it's the solution but it's just a thought of mine. You could try in powershell to run get-spdeletedsite to get a list of site collections removed from the UI, but not completly removed from SharePoint – Christoffer Sep 4 '14 at 11:50
  • I did this whole process and somehow a different site collection got associated with the db. I must have hosed something up in my attempt before posting my question. Thanks for the response! – steveareeno Sep 4 '14 at 12:07
  • Thanks user19952. I deleted my comment because I discovered I messed something up. – steveareeno Sep 4 '14 at 12:09
3

I know your original question was about doing a backup and restore of the content DB. But here is another way of doing it using backup and restore.

You want to use the flag -UseSqlSnapshot in case users are currently using the prod site.

Backup-SPSite  -Identity https://urltomyprodsite –Path "c:\backups\myProdSite.bak" -UseSqlSnapshot

Copy the backup file to the Dev environment and run

Restore-SPSite -Identity http://urlofmynewdevsite -Path "c:\bacups\myProdSite.bak" –DatabaseName <Content DB name to restore to> -DatabaseServer <SQL Server>

The Restore-SPSite cmdlet performs a restoration of the site collection to a location specified by the Identity parameter. A content database may only contain one copy of a site collection. So if you want to restore multiple version from the Prod environment you will need to restore them on different content databases.

Backup-SPSite

Restore-SPSite

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.