Print View

OSQL.EXE fails with "Cannot open backup device" when using "BACKUP DATABASE" query

Issue

When running a osql query to backup a database to disk to "Cannot open backup device" error may be seen:

osql -S server\instance -E -Q "BACKUP DATABASE database TO DISK = '\\server\share\database.bak'"

Msg 3201, Level 16, State 1, Server server\instance, Line 1
Cannot open backup device '\\server\share\database.bak'. Operating system error 5(error not found).
Msg 3013, Level 16, State 1, Server server\instance, Line 1
BACKUP DATABASE is terminating abnormally.


The alternative error may be seen:

Msg 3201, Level 16, State 1, Server server\instance, Line 1
Cannot open backup device '\\server\share\database.bak'. Device error or device off-line. See the SQL Server error log for more details.
Msg 3013, Level 16, State 1, Server server\instance, Line 1
BACKUP DATABASE is terminating abnormally.

Resolution

Ensure the following:

- a UNC path is being used
- the share permissions allow Change or Full Control permissions
- the NETWORK SERVICES account has write permissions to the file system

References

How to back up a Microsoft Data Engine database by using Transact-SQL
http://support.microsoft.com/kb/241397

Products

Microsoft SQL 2005 Express Edition (any)

Created: 22nd April 2009
Updated: 22nd April 2009

Print View

© 2005-2024 Jamie Morrison