How to fix Error 3038 on Windows Server 2025 / Windows 11

Why This Error Happens

SQL Server error 3038 occurs when the file path specified in a BACKUP or RESTORE statement does not conform to a valid Windows file system naming convention, often due to illegal characters, incorrect syntax, or an unreachable UNC path. This can also happen if the target directory does not exist, the SQL Server service account lacks permissions to resolve the path, or the backup device name exceeds the maximum allowed length. Additionally, environment-specific issues like mapped network drives not being visible to the SQL Server service (since it runs as a Windows service, not an interactive user session) frequently trigger this error.

Step-by-Step Resolution Guide

Step 1: Validate the File Path Syntax

  • Open SQL Server Management Studio (SSMS) and review the exact BACKUP statement being executed.
  • Ensure the path uses proper escaping, e.g., BACKUP DATABASE [YourDB] TO DISK = 'C:\Backups\YourDB.bak'.
  • Check for illegal characters such as *, ?, ", <, >, |, or trailing spaces in the file name.
  • Confirm the file extension (.bak, .trn) is included and correctly spelled.

Step 2: Verify Directory Existence and Permissions

  • Navigate to the target directory (e.g., C:\Backups) using File Explorer on the Windows Server 2025 host.
  • If the folder does not exist, create it manually: right-click > New > Folder.
  • Right-click the folder, select Properties > Security, and ensure the SQL Server service account (e.g., NT Service\MSSQLSERVER) has Full Control.
  • Restart the SQL Server service via services.msc if permissions were just updated.

Step 3: Replace Mapped Drives with UNC Paths

  • If the backup path uses a mapped network drive (e.g., Z:\Backups\), convert it to a full UNC path, since SQL Server services cannot resolve user-session drive mappings.
  • Update the statement to use the format: BACKUP DATABASE [YourDB] TO DISK = '\\ServerName\ShareName\YourDB.bak'.
  • Ensure the SQL Server service account has read/write access to the network share itself, not just the local folder.

Step 4: Check for Reserved Names or Length Limits

  • Confirm the backup file name does not use a reserved Windows keyword (e.g., CON, PRN, AUX, NUL).
  • Verify the full path length does not exceed 260 characters, as older APIs within SQL Server 2025 components may still enforce this limit unless long path support is explicitly enabled in Windows Server 2025 Group Policy.

Alternative or Verification Steps

  • Run a test backup command directly in a New Query window in SSMS using a simplified local path (e.g., C:\Temp\test.bak) to confirm the syntax and permissions are functioning correctly before reverting to the original network path.
  • If the UNC path continues to fail, use xp_cmdshell (if enabled) to run a dir \\ServerName\ShareName\ command from within SQL Server to verify the engine’s service account can actually see the remote directory.