Throwing error while restoring msdb database.

  • Hi All

    I am getting errors while restoring the msdb database. In addition, I couldn't able to restart the sql server agent.

    Msg 3634, Level 16, State 1, Line 1

    The operating system returned the error '32(The process cannot access the file because it is being used by another process.)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\msdbdata.mdf'.

    Msg 3156, Level 16, State 8, Line 1

    File 'MSDBData' cannot be restored to 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\msdbdata.mdf'. Use WITH MOVE to identify a valid location for the file.

    Msg 3634, Level 16, State 1, Line 1

    The operating system returned the error '32(The process cannot access the file because it is being used by another process.)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\msdblog.ldf'.

    Msg 3156, Level 16, State 8, Line 1

    File 'MSDBLog' cannot be restored to 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\msdblog.ldf'. Use WITH MOVE to identify a valid location for the file.

    Msg 3119, Level 16, State 1, Line 1

    Problems were identified while planning for the RESTORE statement. Previous messages provide details.

    Msg 3013, Level 16, State 1, Line 1

    RESTORE DATABASE is terminating abnormally.

    Please help me in this.

    Regards,

    Mohanraj Jayaraman

  • set your environment to single user mode and try again.

    _____________________________________
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at Amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
  • when I try that by using sqlservr -c -m -f i am getting below error.

    2008-09-19 14:45:53.82 Server Error: 17058, Severity: 16, State: 1.

    2008-09-19 14:45:53.82 Server initerrlog: Could not open error log file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG'. Operating system error = 32(The process cannot access the file because it is being used by another process.).

    2008-09-19 14:45:54.14 Server Error: 17058, Severity: 16, State: 1.

    2008-09-19 14:45:54.14 Server initerrlog: Could not open error log file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG'. Operating system error = 32(The process cannot access the file because it is being used by another process.).

    2008-09-19 14:45:54.45 Server Error: 17058, Severity: 16, State: 1.

    2008-09-19 14:45:54.45 Server initerrlog: Could not open error log file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG'. Operating system error = 32(The process cannot access the file because it is being used by another process.).

    2008-09-19 14:45:54.76 Server Error: 17058, Severity: 16, State: 1.

    2008-09-19 14:45:54.76 Server initerrlog: Could not open error log file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG'. Operating system error = 32(The process cannot access the file because it is being used by another process.).

    2008-09-19 14:45:55.07 Server Error: 17058, Severity: 16, State: 1.

    2008-09-19 14:45:55.07 Server initerrlog: Could not open error log file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG'. Operating system error = 32(The process cannot access the file because it is being used by another process.).

    2008-09-19 14:45:55.39 Server Error: 17058, Severity: 16, State: 1.

    2008-09-19 14:45:55.39 Server initerrlog: Could not open error log file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG'. Operating system error = 32(The process cannot access the file because it is being used by another process.).

    2008-09-19 14:45:55.70 Server Error: 17058, Severity: 16, State: 1.

    2008-09-19 14:45:55.70 Server initerrlog: Could not open error log file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG'. Operating system error = 32(The process cannot access the file because it is being used by another process.).

    2008-09-19 14:45:56.01 Server Error: 17058, Severity: 16, State: 1.

    2008-09-19 14:45:56.01 Server initerrlog: Could not open error log file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG'. Operating system error = 32(The process cannot access the file because it is being used by another process.).

    2008-09-19 14:45:56.32 Server Error: 17058, Severity: 16, State: 1.

    2008-09-19 14:45:56.32 Server initerrlog: Could not open error log file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG'. Operating system error = 32(The process cannot access the file because it is being used by another process.).

    2008-09-19 14:45:56.63 Server Error: 17058, Severity: 16, State: 1.

    2008-09-19 14:45:56.63 Server initerrlog: Could not open error log file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG'. Operating system error = 32(The process cannot access the file because it is being used by another process.).

  • Make sure no other program is using those files(any antivirus running in background). Also, if you have utilities like filemon you can view the processses using that file..

    HTH

    MJ

  • And make sure that the SQL service and SQL Agent are shut down.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • I've had a similar problem. In my case it was because I was trying to restore to the same mdf and log file that I'd backed up. If you change the filenames of the destination (restore files) to another name e.g. put a 2 at the end of them like

    you've backed up c:\myInvoices.mdf and c:\myInvoices.log

    then you should restore to c:\myInvoices2.mdf and c:\myInvoices2.log

    Worked for me.

  • I am struck with the similar problem....

    The scenario is something like this :

    I have two instances of sql server 2008 r2 on the same server as dv and qa. Important point to be noted here is my databases on both instances has 3 data files ie., 1 Primary mdf file and 2 secondary files with extension .ndf and a log file each.

    I took backup of a database from dv and tried to restore it to qa, when i tried to restore it with the command given below

    RESTORE DATABASE [MyDB_3QA]

    FROM DISK = '\\sbi092\public\Backup\MyDB\MyDB_3Test\MyDB_3Test_DB_20111109.11.47.49_Part1of1.bak' WITH RECOVERY,

    REPLACE,

    MOVE 'MyDB_3QA1_Data'TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.ODSQL02_QA\MSSQL\DATA\MyDB_3QA1_Data.mdf',

    MOVE 'MyDB_3QA_log'TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.ODSQL02_QA\MSSQL\DATA\MyDB_3QA_log.ldf',

    MOVE 'MyDB_3QA2_Data'TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.ODSQL02_QA\MSSQL\DATA\MyDB_3QA2_Data.ndf',

    MOVE 'MyDB_3QA3_Data'TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.ODSQL02_QA\MSSQL\DATA\MyDB_3QA3_Data.ndf'

    It is throwing an error something like

    The operating system returned the error '32(The process cannot access the file because it is being used by another process.)' while attempting 'RestoreContainer::ValidateTargetForCreation' on dv file path

    Another important thing to notice here is when I follow the same process to backup and restore a database with less than 3 data files it is working fine....

    Can anyone figure out the problem and suggest me solution if any.

    Thanks in advance

  • I am having this same issue with trying to restore a backup from instance A to instance B on the same server. did you ever get a solution?

    Thanks!

  • The operating system returned the error '32(The process cannot access the file because it is being used by another process.)' while attempting 'RestoreContainer::ValidateTargetForCreation' on dv file path

    Another important thing to notice here is when I follow the same process to backup and restore a database with less than 3 data files it is working fine....

    Your above tow statements are not mutually related. one thing you need to keep in mind that the data folder where your are keeping mdf and ldf file must be different from each other.and also check the permission of user your are using for restore

    -------Bhuvnesh----------
    I work only to learn Sql Server...though my company pays me for getting their stuff done;-)

  • :w00t:

    Use Sp_Who2 and kill that processes which is using MSDB database.

  • sumit.tembhare (5/4/2012)


    :w00t:

    Use Sp_Who2 and kill that processes which is using MSDB database.

    Killing is not an optimal solution it should be last weapon to use.

    -------Bhuvnesh----------
    I work only to learn Sql Server...though my company pays me for getting their stuff done;-)

  • sumit.tembhare (5/4/2012)


    :w00t:

    Use Sp_Who2 and kill that processes which is using MSDB database.

    SQL processes using the MSDB database would not give the error "The process cannot access the file because it is being used by another process.".

    That error is given when SQL Server cannot open the file because some other windows process has the file open. Nothing to do with SQL connections

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • It is related with SQL bt yes, process is running from windows.Check any windows utility is running parallaly like diskFrag or May be a batch file is using that database.

  • While not likely the msdb could have been restored from a backup that did not have the same logical name, you may wish to check on what logical name is expected to be read from the backup.

    http://stackoverflow.com/questions/7089627/how-can-i-retrieve-the-logical-file-name-of-the-database-from-backup-file

    Jamie

Viewing 14 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic. Login to reply