none
Recover sitecollection from SQL backup on same Sharepoint Farm

    Question

  • i want to recover/duplicate a site collection from SQL backup on the same Sharepoint Farm, i tried the following with no luck.

    1. i took backup via SQL Mgmt Studio

    2. Restorted the DB backup with a different name on same SQL server

    3. Created a new web application on same farm

    4. tried attaching new database but it gave error that database id is same

    5. so used the command "Mount-spcontentdatabase" with "Assingnewdatabaseid" and databased got attached sucessfully

    6. But unable to access the site collection (also "current number of site collections" is "0" under "manage content database")

    what is the proper procedure to duplicate / restore the site collection to same farm (on to a different web application)

    Tuesday, December 17, 2013 5:10 AM

Answers

All replies

  • This won't work, as the Site Collections will have the same GUID as existing Site Collections, and the GUID needs to be unique per-farm.

    So you can either restore your Content Database to a new farm, or use Backup-SPSite and restore the Site Collection using Restore-SPSite *to a different content database* (restoring to the same content database will yield a pathing issue).


    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, December 17, 2013 5:19 AM
    Moderator
  • Dear Nuplius, please find my worries in italic and advice

    This won't work, as the Site Collections will have the same GUID as existing Site Collections, and the GUID needs to be unique per-farm.

    IS there a way to change the GUID of site collection while restoration (similar to Assingnewdatabaseid)

    So you can either restore your Content Database to a new farm, or use Backup-SPSite and restore the Site Collection using Restore-SPSite *to a different content database* (restoring to the same content database will yield a pathing issue).

    I tried restoring content database to new farm and attached DB to different site collection and it worked. Then i deleted the site collection, removed the database and attached again, this time it did not work. this works only one time. But it is not practical to create a new farm each time i want to restore the content.

    Backup-SPsite is useful only if the source site is working, what if the source site is corrupted and i have DB backup and want to use the same farm to recover the corrupted site collection. (i can not install other farm because there are other site collections which are in use)

    Tuesday, December 17, 2013 11:00 AM
  • You can use the SharePoint GUI to backup a site collection from an unattached content database.

    This guide seems to fit your needs?: http://www.petri.co.il/restore-from-unattached-content-database-sharepoint-2013.htm

    Tuesday, December 17, 2013 11:10 AM
  • Thanks for the article .. i have'nt tried it out.

    But Alex can let me know you, will this process assign a new GUID for site collection

    (i.e. will this process allow to have duplicate copy of site collection on the same farm).

    Tuesday, December 17, 2013 1:15 PM
  • You cannot assign a new GUID to a Site Collection. I do restores of content databases to the same farm all of the time, so unattaching/deleting and then re-attaching will work.

    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, December 17, 2013 4:48 PM
    Moderator
  • are you just want to make a copy of your current site collection or you want it restore from previous date?

    if just copy then you can use the Copy-Spsite command to achieve this, this way you will get a new url and new site id:

    Copy-SPSite http://contoso/sites/OldTeam -DestinationDatabase WSS_Content -TargetUrl http://contoso/sites/NewTeam

    http://technet.microsoft.com/en-us/library/fp161280.aspx


    Please remember to mark your question as answered &Vote helpful,if this solves/helps your problem. ****************************************************************************************** Thanks -WS MCITP(SharePoint 2010, 2013) Blog: http://wscheema.com/blog

    Wednesday, December 18, 2013 4:33 AM
    Moderator
  • Copy-SPSite is only used for upgrade and migration, not for day-to-day use or duplicating content.

    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.

    Wednesday, December 18, 2013 4:37 AM
    Moderator
  • this is what MSFT saying about this.

    "Use the Copy-SPSite cmdlet to make a copy of a site collection from an implied source content database to a specified destination content database.The copy of the site collection has a new URL and a new SiteID. When you have database snapshot capabilities on a computer runningSQL Server, a temporary snapshot of the source database is created for the duration of the copy to prevent any data changes during the copy process. If you do not have database snapshot capabilities on the server running SQL Server, you can back up the source and restore it to the destination to get the same result."

    http://technet.microsoft.com/en-us/library/fp161280.aspx


    Please remember to mark your question as answered &Vote helpful,if this solves/helps your problem. ****************************************************************************************** Thanks -WS MCITP(SharePoint 2010, 2013) Blog: http://wscheema.com/blog

    Wednesday, December 18, 2013 4:39 AM
    Moderator
  • Note that TechNet documentation is not always accurate, and what I posted comes from a PFE:

    First of all, the Copy-SPSite commandlet is a upgrade and migration command that is intended to be used to make a copy of a site collection with its content being written into a user specified content database.  Typically this command is used to make copies of site collections that can be used to validate the upgrade process.   It wasn’t really intended to be used as part of day to day operations and has limitations that prevent it from being used for this purpose


    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.

    Wednesday, December 18, 2013 4:41 AM
    Moderator
  • alright, but we had been used this couple of time in past to achieve same goal and our PFE support this.

    Please remember to mark your question as answered &Vote helpful,if this solves/helps your problem. ****************************************************************************************** Thanks -WS MCITP(SharePoint 2010, 2013) Blog: http://wscheema.com/blog

    Wednesday, December 18, 2013 4:45 AM
    Moderator
  • Unfortunately it isn't a supported method. Use Backup-SPSite/Restore-SPSite if you need to duplicate sites within the same farm.

    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.

    Wednesday, December 18, 2013 5:33 AM
    Moderator
  • Thanks for your inputs...let me explain my scenario here. Please advice what needs to be done in the below case (assuming there is only 1 sql server, 1 sharepoint farm and we can not install more farms or sql servers)

    One of my user wants to retrieve an excel file which is corrupted, so what i did is

    1. from SQL backup i restored 3 days back sql database to same sql server with a different name sucessfully.

    2. created a new temp webapplication on the same farm and then a root site collection as blank site.                

    3. Attached the restored database (with different name) to new temp webapplication, it errored say same database id. 

    4. then attached the database using "Mount-spcontentdatabase" with "Assingnewdatabaseid" sucessfully

    5. But still i am not able to site collection / access the files (manage content db shows site collections as 0)

                                                                                                                                    

       

    Wednesday, December 18, 2013 6:41 AM
  • You're seeing the correct behavior due to having the same site collection id. In your case, I would suggest an unattached database content restore.  http://technet.microsoft.com/en-us/library/hh269602.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.

    • Marked as answer by JasonGuo Sunday, December 29, 2013 2:47 PM
    Wednesday, December 18, 2013 6:48 AM
    Moderator
  • As Trevor mentioned, your best bet is the

    take the backup of site collection using Unattached Content DB option.

    then restore it via restore-spsite.

    once it restored then you can get the excel document.

    here is good blog for complete steps:

    http://blog.sharepoint-recovery.com/2010/06/25/sharepoint-2010-unattached-content-database-recovery-not-recovery-just-export/


    Please remember to mark your question as answered &Vote helpful,if this solves/helps your problem. ****************************************************************************************** Thanks -WS MCITP(SharePoint 2010, 2013) Blog: http://wscheema.com/blog

    • Marked as answer by JasonGuo Sunday, December 29, 2013 2:47 PM
    Wednesday, December 18, 2013 3:26 PM
    Moderator
  • I ran into similar issues and coded a PowerShell script to generate a new SPSite GUID number.   After that runs, you can consume the same SPSite twice on the parent farm.  No more GUID conflict.

    NOTE - This is completely unsupported.  Use at your own risk.   Worked well on Dev and Test environments for me.

    http://www.spjeff.com/2017/05/22/clone-content-database-sql-copy-generate-spsite-guid/



    @SPJeff | www.spjeff.com


    • Edited by SPJeff Monday, May 22, 2017 4:42 PM
    Monday, May 22, 2017 4:42 PM