sql-server-maintenance-solution icon indicating copy to clipboard operation
sql-server-maintenance-solution copied to clipboard

Cannot create a file when that file already exists.

Open MaiklT opened this issue 4 years ago • 2 comments

Description of the issue

Sometimes it happens that the above error message appears. As far as I can see, the script tries to create a folder for the backup files, but runs into this error when the folder already exists.

SQL Server version and edition Microsoft SQL Server 2019 (RTM-CU13) (KB5005679) - 15.0.4178.1 (X64) Sep 23 2021 16:47:49 Copyright (C) 2019 Microsoft Corporation Standard Edition (64-bit) on Windows Server 2019 Standard 10.0 <X64> (Build 17763: ) (Hypervisor)

Version of the script 2020-12-31 18:58:56

What command are you executing? DatabaseBackup - USER_DATABASES - LOG, but it happens also with other DatabaseBackup commands,

What output are you getting?

Date and time: 2021-11-29 14:30:02 [SQLSTATE 01000]
Database context: [master] [SQLSTATE 01000]
Command: DECLARE @ReturnCode int EXECUTE @ReturnCode = dbo.xp_create_subdir N'\\x.x.x.x\MyBackupShare\SQLServerName\DatabaseName\LOG' IF @ReturnCode <> 0 RAISERROR('Error creating directory.', 16, 1) [SQLSTATE 01000]
Msg 22048, Sev 16, State 1: xp_create_subdir() returned error 183, 'Cannot create a file when that file already exists.' [SQLSTATE 42000]
Msg 50000, Sev 16, State 1, Line 1 : Error creating directory. [SQLSTATE 42000]
Outcome: Failed [SQLSTATE 01000]
Duration: 00:00:00 [SQLSTATE 01000]

Normally, the next scheduled backup runs as expected.

MaiklT avatar Nov 29 '21 13:11 MaiklT

Does it normally happen after a new database has been created, or it can happen at any time?

Have you seen any pattern for when it happens?

olahallengren avatar Jan 01 '22 22:01 olahallengren

Sorry for the late reply. It can happen any time, and no - there is absolutely no time pattern. Completely coincidental.

I should add the information that the backup drive is a fileshare outside the Windows Domain.

MaiklT avatar May 03 '22 06:05 MaiklT