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

Troubleshooting Guide: SQL Server Error 3761 – Could Not Delete SBS Backed File

Why This Error Happens

Error 3761 occurs when SQL Server’s Snapshot Backup Service (SBS) attempts to clean up a file that was backed by a VSS-based snapshot backup, but the operation fails due to the file being locked, missing, or inaccessible. This is typically caused by insufficient file system permissions for the SQL Server service account, a corrupted or orphaned snapshot metadata entry, or a third-party VSS provider/backup tool holding an exclusive lock on the underlying file. In some cases, the issue stems from a mismatch between the snapshot backup metadata in msdb and the actual state of files on disk, often after an interrupted or forcibly terminated backup job.

Step-by-Step Resolution Guide

Step 1: Verify File System Permissions and File State

  • Open File Explorer or PowerShell and navigate to the SQL Server data directory (typically C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\).
  • Confirm the file referenced in the error (%ls placeholder in the actual message) exists and check its lock status using Handle.exe or Resource Monitor.
  • Ensure the SQL Server service account (e.g., NT Service\MSSQLSERVER) has Full Control permissions on the file and parent directory.
  • Run: icacls "C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\<filename>" to audit current permissions.

Step 2: Check and Restart the VSS and SQL Writer Services

  • Open Services (services.msc) and confirm SQL Server VSS Writer and Volume Shadow Copy services are running.
  • Restart both services in this order via PowerShell (run as Administrator):
  • net stop "SQLWriter"
  • net stop "VSS"
  • net start "VSS"
  • net start "SQLWriter"
  • Clear any stale VSS shadow copies that may be holding file locks: vssadmin list shadows followed by vssadmin delete shadows /for=<volume> /oldest if orphaned copies are found.

Step 3: Clean Up Orphaned Snapshot Backup Metadata

  • Connect to the SQL Server instance using SQL Server Management Studio (SSMS) or sqlcmd.
  • Query msdb.dbo.backupset and msdb.dbo.backupmediafamily to identify stale snapshot backup records referencing the problematic file.
  • Run DBCC CHECKDB on the affected database to rule out corruption: DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS;
  • If the file is confirmed orphaned and unreferenced by any active database, manually remove it from disk after taking a full backup, then restart the SQL Server service to force metadata resynchronization.

Step 4: Review the SQL Server Error Log for Underlying Cause

  • Open the SQL Server Error Log via SSMS (Management > SQL Server Logs) or navigate to C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG.
  • Search for accompanying error codes or OS-level error messages (e.g., Error 5 – Access Denied, or Error 32 – File in use) that appear immediately before or after Error 3761.
  • Cross-reference the timestamp with Windows Event Viewer (Applications and Services Logs > Microsoft > Windows > NTFS) to identify any file system-level conflicts.

Alternative or Verification Steps

  • To verify the fix, re-run the snapshot backup job manually using BACKUP DATABASE ... WITH SNAPSHOT and confirm no errors appear in the SQL Server Error Log afterward.
  • If the issue persists, consider disabling third-party antivirus or backup agent real-time scanning on the SQL Server data directory, as these tools frequently cause file-handle conflicts with VSS snapshot operations.