Restored the content DB backup to new web-app, shows "number of sites in content DB = 0" RRS feed

  • Question

  • Hi,

    I have a MOSS 2007 single server farm env. I am trying to recover a site collection that was accidently deleted. For this I followed below steps:

    1. Restore the content DB backup to a TEMP database. (SQL generates daily backups for all sharepoint DBs)
    2. Create a new web-application TEMPAPP and create a site collection in it.
    3. Remove the content DB for TEMPAPP web-application
    4. Add the TEMP databse as content DB for TEMPAPP

    This should technically allow me to access all the content present in the backup including the deleted site collection.
    However the Content Databases page shows that the number of sites in it is zero. And so when I try to access the sites in TEMPAPP web-application I get '404 - page not found error'.

    I have used this exact procedure numerous time before without any problem.

    I also tried to restore the database backup in a seperate farm, to ensure that the duplicate site-ID is not the issue. I did the same steps, but the problem remains #site in content DB = 0.

    Does anyone have any idea why this is happening?

    NOTE: I checked the webs table and it has all the sites. So the data is there. Then why is it not showing up on SharePoint?


    Tuesday, April 20, 2010 1:19 AM


All replies

    1. Are you 'attaching' the database using stsadm or gui?
    2. What is the size of the db?


    Blog: Alpesh Nakar's Blog | Twitter: Follow Alpesh on Twitter |SharePoint Resources: Just SharePoint Resource Center | Follow Just SharePoint updates on Twitter
    Tuesday, April 20, 2010 2:33 AM
  • Attaching using GUI. Size is around 2.5 GB with 5 GB log file.
    I am not sure if it is ok to truncate the log but I guess that does not matter in the current issue.
    Tuesday, April 20, 2010 4:36 AM
  • Monali,

    Honestly I am not a big fan of GUI :)

    Can you try with stsadm to attach the database to the web application?

    On a side note, I would refrain from creating the site collection as well. Just create the web app, detach and attach via stsadm


    Blog: Alpesh Nakar's Blog | Twitter: Follow Alpesh on Twitter |SharePoint Resources: Just SharePoint Resource Center | Follow Just SharePoint updates on Twitter
    Tuesday, April 20, 2010 4:52 AM
  • Thank you Alpesh. I will try that.
    Tuesday, April 20, 2010 5:09 AM
  • I tried the stsadm addcontentdb but its has the same issue. no sites listed on content db page.
    Tuesday, April 20, 2010 6:14 PM
  • So Try  stsadm deletecontentdb command first and then use addcontentdb command.And before backup of the data make sure the collation of the database , check the database size after back up.
    Wednesday, April 21, 2010 1:51 AM
  • Hi Monali G,

    After you create a new web application, don’t create a site collection in it but just attach the restored database to it using command line. For detailed steps, please follow this article:


    Hope this helps.

    Lu Zou

    Wednesday, April 21, 2010 3:30 AM
  • I have faced this issue earlier... There are mainly two reasons for this to happen.

    1> either the DB has not been attached properly.

    2> the database which you restored is a corrupt one.

    Inorder to check if the database is a valid one, with site collections in it.. i woul suggest you to connect to the db using SQL management studio.

    then run the sql statement

    select * from sites

    If I remember correctly, its the sites table which contain the list of site collections , the number which you see besides the content database after adding it is the count of the sites table..

    run this and see if there are any data in it or not. If its not there, then it means the database back up was corrupt. if the results are the desired one, then i would suggest you to attach and detach and reattach again..

    that would be my suggestion. hope this helps.

    Wednesday, April 21, 2010 4:25 PM
  • Thank you for your suggestions Alpesh, spsrocks, Lu, ssm225in.
    Unfortunately none of them could resolve the problem.

    Figured out the reason for not being able to restore DB with the help of MS support. The reasons were:

    1. The SPTimer job was stuck - Had to reset the timers using stsadm execadmsvcjobs command.
    2. Cache.ini needed reset - Not sure about what this file is but following links give some info.

    Sometimes the issue is with something which you don't expect. This was one classic case.


    • Marked as answer by Monali G Friday, April 23, 2010 10:12 PM
    Friday, April 23, 2010 10:12 PM
  • Hi,

    Use the Restore-SPDeletedSite cmdlet to restore a previously deleted site collection.

    This link helped to get rid of this issue :



    Thursday, January 7, 2016 3:05 PM