locked
Copy-SpSite for duplicating training environments RRS feed

  • Question

  • So I work in training people on SharePoint and we were setting up an environment for students to work out of.  I got the idea that "hey, copy-spsite copies a site so we can just use that to duplicate the 'master' site".

    Well, I found when I was going through our curriculum that it has a small quirk.  When I use copy-spsite to duplicate sites, it appears that it duplicates items in the recycle bin.  If I duplicate the sites and then delete something, there are then two items in the recycle bin.  If I try to restore any of the items, I get an error that there is not a unique item in the Database so the action failed.

    I know this is a kind of non-standard way of doing things and in production might not be the way to go about things... but it would be REALLY convenient to be able to duplicate sites this way.  Has anyone ever seen this, know a way around it, or know a way to prevent it?

    Thanks.

    Tuesday, October 22, 2013 2:59 PM

Answers

All replies

  • Why not export the site (Export-SPWeb) or create a re-deployable site template?  I haven't run into the particular issue you're seeing.

    Trevor Seward, MCC

    Follow or contact me at...
      

    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

    Tuesday, October 22, 2013 3:42 PM
  • And that's what we do at the moment...  we use an exported master site to import for every student site collection.  It just takes a bit for it to complete.  We have it scripted so it's pretty much automated, but the copy-spsite would be really convenient and seems faster to me.

    I'll double check it and see if I can get some screenshots.  Like I said, this is fairly non-standard way to use it.  My understanding I that copy-spsite is usually used to move a site which wouldn't run into this if you deleted the original.  Or if you moved between farms, I suppose.

    Tuesday, October 22, 2013 6:42 PM
  • So we had to rebuild our 2013 environment for various reasons and I was hoping that the copy-spsite problem was just a glitch from the first build.  But when I copied one of the student sites to another URL the problem is still there.  I added a document and then deleted it. When I go to the recycle bin, the picture below is what I see.

    I copy-spsite again to another URL and refresh the recycle bin page to get three of the same item, etc.

    Now when I try to restore one of the items, I get an error of it can't be done with a correlation ID.  When I look up the correlation ID in the logs, I find the message "System.Data.SqlClient.SqlException (0x80131904): Subquery returned more than 1 value."

    So, to me, it looks like when you use copy-spsite that it duplicates the recycle bin but somehow links them as well.  It's very inconvenient when trying to duplicate sites.  I'm currently exporting and importing sites but that takes about 10 times as long. 

    (edit:  so when I try to post it says I can't add pictures because my account is not verified.  When I do a search for how to verify my account, the basic answer is that you eventually will be able to post pictures, etc.. and there is not a specific way.  Someday, it'll just happen.  so no pictures and I'm not rewriting the post.  Still if anyone else wants to try this and post screen grabs, I'd appreciate it.)

    Friday, November 1, 2013 3:41 PM
  • If you're using PowerShell then you could just empty the recycle bin as a preparatory step? It's not a perfect fix but it might deal with your particular issues.

    From memory you might need to disable the bin and re-enable it to empty it.

    Friday, November 1, 2013 4:20 PM
  • If you're using PowerShell then you could just empty the recycle bin as a preparatory step? It's not a perfect fix but it might deal with your particular issues.

    From memory you might need to disable the bin and re-enable it to empty it.


    I just tried it, but once someone deletes something you wind up with the same number of copies in the recycle bin as number of times that you copied the site.  It doesn't seem to matter when you delete the item, it only matters the number of times you copied the site...  Very strange.
    Tuesday, November 19, 2013 7:32 PM
  • First and second stage recycle bins?
    Wednesday, November 20, 2013 9:33 AM
  • FYI I was reading this recently that Copy-SPSite is only purposed for site upgrades and no other uses. What you're trying to do would basically fall under 'not supported'.

    http://blogs.msdn.com/b/erica/archive/2013/11/26/customer-question-renaming-site-collections-in-sharepoint-2013.aspx


    Trevor Seward, MCC

    Follow or contact me at...
      

    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

    Sunday, December 1, 2013 5:01 PM
  • Which brings us to the next logical step: why don't you use:

    Procedure :

    -          - Export site collection

    -          -          Import site coll

    Export (http://technet.microsoft.com/en-us/library/ee748617.aspx):

    Backup-SPSite -Identity <SiteCollectionGUIDorURL> -Path <BackupFile> [-Force] [-NoSiteLock] [-UseSqlSnapshot] [-Verbose]

    Where:

    <SiteCollectionGUIDorURL> is the ID or URL for the site collection you want to back up.

    <BackupFile> is the path to where the backup file is located.

    Import (http://technet.microsoft.com/en-us/library/ff607788.aspx):

    Restore-SPSite

    Restores a site collection

    Restore-SPSite http://server_name/sites/site_name -Path C:\Backup\site_name.bak

    This example restores a site collection from the backup file C:\Backup\site_name.bak to the site collection URL http://server_name/sites/site_name.


    Kind regards,
    Margriet Bruggeman

    Lois & Clark IT Services
    web site: http://www.loisandclark.eu
    blog: http://www.sharepointdragons.com

    Friday, January 10, 2014 7:58 AM