problem restoring a database in other intance of same sarver

Answered problem restoring a database in other intance of same sarver

  • Wednesday, July 11, 2012 11:50 PM
     
     

    hi hope you can help me, I will first give an overview of what I do.
    I am creating a script in powershell for the restare of SharePoint web applications on other farms, it is necessary to make a backup of all the elements that are to recreate or restore a new farm, as such require a new database server data.
    I did this allready by graphics means you could say (with the central administration and sql server), I do a web application backup, went i try to restore it I went out an error  but I solve it by restoring the .bak file directly to the new instance of sql, then created a new site collection with powershell and associate that site colletion to the restored database.

    Now I want to do just that but all in a powershell script, now the problem is this, When i did this by the graphic method using 2 different sql servers with different instances, we will call the first or primary A(production), and restored for the first time B(development) . Now for powershell, since the web application B is a replica of  A (to be my production web application and B my web application for development), this way I can modify  B without affecting A or my web application in production. Copies or restorations would be based on B, now in this farm B is a sql server B which also has n number of instances, B1, B2, .... Bn instances although these have their SharePoint farms.

    Now the problem is that to do the backup of the web application you need a shared folder that the administrator sharepoint and sql server can access to save the backup there, however when attempting to restore the . bak of the database to the instance that belongs to the B1 to the instance B5, I make an error that reads:

    Restore Failed for server 'sqlserver \ B5' (Microsoft.sqlServer.SmoExtended)

    System.Data.SqlClient.SqlError: The operating system Error Returned the '32 (The process can not access the file Because it is Being Used by another process.) 'While Attempting' RestoreContainer :: ValidateTargetForCreation 'on' C: \ Program Files \ Microsoft SQL Server \ MSSQL10_50.B1 \ MSSQL \ DATA \ WSS_Content_.mdf '. (Microsoft.SqlServer.Smo)

    and this error appears even if I move the file to the root C where is the sql server, however if I try to restore a .bak from farm A to  any instance of farm B does not get this error, any ideas?

    I hope I have explained

All Replies

  • Thursday, July 12, 2012 12:13 PM
     
     Answered

    Hello,

    A few thoughts.

    1. Is there any antivirus or antimalware software that would be scanning the file? Double check exclusion lists.

    2. Does the SQL Server engine account have access to the specified folders?

    3. Instead of using the GUI, have you tried issuing just the restore database command through a query? If not, try this and see if the error is the same.

    If all else fails, I would download sysinternals process explorer and see which process has the file open.

    -Sean


    Sean Gallardy, MCC | Blog