Help: SQL Server

Sharing my knowlege about SQL Server Troubleshooting Skills

  • Blog Stats

    • 2,037,796 hits
  • Select GETDATE()

    March 2014
    M T W T F S S
     12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31  

Troubleshooting : Msg 3201 – Cannot open backup device .. Operating system error 3(The system cannot find the path specified.)

Posted by blakhani on March 13, 2014


Data recovery is a time consuming and expensive process. Taking regular backups can save a lot of time as well as make sure that the data can be restored in the case of disaster. There could be many situation where backup of the database taken in SQL Server might fail with 3201 error. The text of error id as below (you can use sys.messages catalog view to get it)

Cannot open backup device ‘%ls’. Operating system error %ls.

Same message is applicable for restore as well, it’s all about unable to open device. If we notice %ls is placeholder which would be inserted when message is raised. Some sample errors are as below.

Message # 1

Msg 3201, Level 16, State 1, Line 1
Cannot open backup device ‘E:\Backup\SQLServerHelp.bak’. Operating system error 3(The system cannot find the path specified.).

Cause: Backup folder not created on E Drive.

Message # 2

Msg 3201, Level 16, State 1, Line 1
Cannot open backup device ‘C:\SQLServerHelp.bak’. Operating system error 5(Access is denied.).

Cause: SQL Server Service account is not having permission on root of C Drive.

Message # 3

Msg 3201, Level 16, State 2, Line 1
Cannot open backup device ‘\\NetworkShare\Backup\SQLServerHelp.BAK’. Operating system error 53(error not found).

This one is interesting because it doesn’t tell the exact message for OS error 53. Sometime this could happen with any other OS error as well. Refer my earlier post here where I showed how to get text for an operating system error number. 53 = The network path was not found.

Cause: Network Path: \\NetworkShare\Backup was incorrect.

OK. Let me stop here.. I didn’t plan to discuss all the possible errors but this blog is to present one interesting scenario which helped me uncovering an operating system concept.

Let’s create a database using below script.

Create Database [SQL Server Help ]

Once database is created I have created maintenance plan to take full backup of the database.

image

When I executed above maintenance plan, it failed with error:

image

TITLE: Execute Maintenance Plan

——————————

Execution failed. See the maintenance plan and SQL Server Agent job history logs for details.

——————————

ADDITIONAL INFORMATION:

Job ‘SQLServerHelp.Subplan_1’ failed. (SqlManagerUI)

——————————

BUTTONS:

OK

——————————

If we look at the folder, the folder got created but backup failed. Looked into ERRORLOG and found below

2014-03-13 06:20:31.66 spid65      Error: 18204, Severity: 16, State: 1.

2014-03-13 06:20:31.66 spid65      BackupDiskFile::CreateMedia: Backup device ‘E:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Backup\SQL Server Help \SQL Server Help _backup_2014_03_13_062031_6415729.bak’ failed to create. Operating system error 3(The system cannot find the path specified.).

2014-03-13 06:20:31.66 Backup      Error: 3041, Severity: 16, State: 1.

2014-03-13 06:20:31.66 Backup      BACKUP failed to complete the command BACKUP DATABASE SQL Server Help . Check the backup application log for detailed messages.

when I looked at folder structure, I found that there is a folder “SQL Server Help” got created under “E:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Backup” but still backup was failing. I ran profiler to see the command being fired.

BACKUP DATABASE [SQL Server Help ] 
TO  DISK = N'E:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Backup\SQL Server Help \SQL Server Help _backup_2014_03_13_062920_6305771.bak' 
WITH NOFORMAT, NOINIT,  NAME = N'SQL Server Help _backup_2014_03_13_062920_6305771', 
SKIP, REWIND, NOUNLOAD,  STATS = 10

 

When I executed the command, it failed with below error.

Msg 3201, Level 16, State 1, Line 1

Cannot open backup device ‘E:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Backup\SQL Server Help \SQL Server Help _backup_2014_03_13_062920_6305771.bak’. Operating system error 3(The system cannot find the path specified.).

Msg 3013, Level 16, State 1, Line 1

BACKUP DATABASE is terminating abnormally.


Again, something wrong with the path where I am taking backup. Do you see any problem in above message. Look closer.. there is a space at the end in the folder name where backup is attempted. “SQL Server Help “. If you try to create a folder with the whitespace at the end, operating system would trim the space at the end. This is documented here

The root cause of my problem was name of the database where I have added an space at the end intentionally. Go back and have a look at create database statement which I have used. I also participated in this discussion where same problem was posted long back.

Hope you have learned something new!

  • Cheers,
  • Balmukund Lakhani
  • Twitter @blakhani
  • Author: SQL Server 2012 AlwaysOnPaperback, Kindle
  • Advertisement

    8 Responses to “Troubleshooting : Msg 3201 – Cannot open backup device .. Operating system error 3(The system cannot find the path specified.)”

    1. Hameed Ahmed said

      Wonderful post but I waas wondering if you could write a litte more on this subject? I’d be very thankful if you could elaborate a little bit further. Thanks!

    2. Ashish said

      I am getting this alert continuously for database.:
      Alert description: BackupDiskFile::CreateMedia: Backup device ‘L:\PSC01\BACKUP\recorder.bak’ failed to create. Operating system error 3(The system cannot find the path specified.).

      After like every couple of days the alerts are coming and there closure also. The above drive mentioned in the alert is already got removed from the server around a month back and don’t know how we are receiving the closure also and also we didn’t found anything from our end, because we have a separate backup job which is running successfully everyday.

      Please help.

      • blakhani said

        I have worked on similar issue and default trace helped in finding source of backup command. It was identified that there was some third party backup running on different server sending backup command to this server.
        Are you seeing backup failure on specific times.

    3. Henry said

      Another reason you might receive the error “Cannot open backup device ‘…’. Operating system error 3 (The system cannot find the path specified.).” is because you might have created the backup directory on your local machine.

      Because the backup facility is relative to the physical server upon which SQL Server installed, you will meed to go to your SQL Server node and create your directory structure there.

    4. Ken Parkinson said

      Great post. I used to be checking constantly this weblog and I am inspired!
      Extremely helpful information specially the final phase 🙂 I maintain such info much. I used to be seeking this certain information for a very long time. Thank you and good luck.

    5. Pawan said

      Thanks Balmukund

    6. Thanks forr sharing this

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out /  Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out /  Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out /  Change )

    Connecting to %s

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

     
    %d bloggers like this: