Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a test environment which has a different URL and a different database server than the production environment. I’ve taken a backup of the production content database of mysite and attached it to my test Sql Server. I’ve checked that the administrator accounts we use (sp_admin, sp_app) are db-owners, but still it all fails.

I’ve tried to run a script (see below), to see if I could get any lead, but it seems that the site collections on the web application does not exist.

$siteUrl = Read-Host "Enter Site URL"

$rootSite = New-Object Microsoft.SharePoint.SPSite($siteUrl)
$spWebApp = $rootSite.WebApplication

foreach($site in $spWebApp.Sites)
{
    foreach($siteAdmin in $site.RootWeb.SiteAdministrators)
    {
        Write-Host "$($siteAdmin.ParentWeb.Url) - $($siteAdmin.Name)"
    }
    $site.Dispose()
}
$rootSite.Dispose()

Production server result:

production server result

Test server result:

Test server result

And if I try to add/change the site collection administrator of mysites, the site is not there either. I’m running out of options, and would as next step lose the content database, create a new My Site instance and start from scratch (using the guide Configuring My Site in SharePoint 2010).

central admin site collection administrator


Edit

The Database is mounted correct: Get-SPContentDatabase result


The best option would be to solve the current issue, but is it possible? Where do I start looking for a solution to this problem?

share|improve this question
    
Benny, taking database backup and restoring will never do the job... Why didn't you take backup from Central Admin and Restore from Central Admin? –  Arsalan Adam Khatri Nov 21 '12 at 12:59
    
@ArsalanAdamKhatri Because I'me new to SharePoint and know my way around SQL Server :P. However, If we do a backup from Central Admin in Production and restore the database from Central Admin in Test - it would work? –  Benny Skogberg Nov 21 '12 at 13:06
    
What you're trying to do is a perfectly acceptable practice that's done every day. See my answer below for a possible solution. –  webdes03 Nov 21 '12 at 13:07
    
Backup and restore via SQL is a perfectly acceptable practice, and in many environments is far more efficient than backing up through Central Admin. –  webdes03 Nov 21 '12 at 13:13
add comment

2 Answers

up vote 2 down vote accepted

You say you attached it to the SQL server, but did you mount it to the SharePoint farm using PowerShell? After you do your backup/restore from prod to test, you must ensure the correct SQL permissions, then run Mount-SPContentDatabase to actually mount that database into SharePoint.

To test if this is there or not, run Get-SPContentDatabase. If you don't see your MySite database there, then it hasn't been mounted.

Also, you can be a bit cleaner with your PowerShell and simply use the Get-SPSite and Get-SPWebApplication cmdlets that ship with SharePoint. This is a lot easier than mapping new objects and they'll auto-dispose when you're done, so you don't have to do that by hand.

share|improve this answer
    
Thanx @webdes03, but the database is mounted correct (se my updated question, in the edit section). There must be something else I do wrong... –  Benny Skogberg Nov 21 '12 at 13:19
    
Did you previously have a database mounted under the same name? Did you unmount that one before you mounted the new one? –  webdes03 Nov 21 '12 at 13:20
    
Yes I did have a content database with the same name, and no I didn't unmount it. Should I unmount and mount again? –  Benny Skogberg Nov 21 '12 at 13:22
1  
Yes... you can't just replace the database. There's processes SharePoint has to run to analyze the database, so that's likely the problem. Unmount the database and remount it. –  webdes03 Nov 21 '12 at 13:24
    
Cool! The CurrentSiteCount went from 3 to 874 instances. Looks like you know what you're doing :-) Thanks alot! –  Benny Skogberg Nov 21 '12 at 13:37
show 2 more comments

Create a new Mysite with the restored DB. it needs to be with Proper Manage paths.

Also can you pls put in details with steps what you are doing.

your best best would be:

Create a new web app. Create a new Mysite with the restored DB and see how it goes. or create a new Mysite with new DB. Verify its working > Remove the DB from existing new Mysite and add the resotred DB.

share|improve this answer
    
Thank you for your answer, but I already solved this problem with dismount the old db and mount the new db. Removing the entire web app and start over would be to go to far... imho –  Benny Skogberg Nov 23 '12 at 7:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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