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

Troubleshooting Guide: Error 3139 – Restore to Snapshot Not Allowed with Master Database

Why This Error Happens

Error 3139 occurs because SQL Server explicitly prohibits restoring the master database from a database snapshot, as master itself cannot have snapshots created against it in a usable restore context. This restriction exists because master stores critical instance-level metadata (logins, configuration, linked servers), and a snapshot-based restore could leave the instance in an inconsistent or unrecoverable state. Attempting a RESTORE DATABASE master FROM DATABASE_SNAPSHOT command, or using tools/scripts that generalize snapshot-restore logic across all databases, triggers this error.

Step-by-Step Resolution Guide

Step 1: Confirm the Restore Target

  • Verify that the database you are attempting to restore from a snapshot is not master.
  • Run SELECT name FROM sys.databases WHERE name = 'master'; to confirm the system database context.
  • If your script loops through all databases for snapshot restores, explicitly exclude master, model, msdb, and tempdb.

Step 2: Use a Full Backup Strategy for Master Instead

  • Since snapshots are not supported for master, rely on native full backups.
  • Open SQL Server Management Studio (SSMS) on your Windows Server 2025 / Windows 11 instance and run:
  BACKUP DATABASE master TO DISK = 'C:\SQLBackups\master.bak' WITH INIT;
  • To restore master, you must stop the SQL Server service, start it in single-user mode via command prompt:
  NET STOP MSSQLSERVER
  sqlservr.exe -m -s MSSQLSERVER
  • Then restore using:
  RESTORE DATABASE master FROM DISK = 'C:\SQLBackups\master.bak' WITH REPLACE;

Step 3: Audit Automation Scripts and Maintenance Plans

  • Check SQL Server Agent jobs, PowerShell scripts, or third-party backup tools (e.g., Ola Hallengren’s maintenance solution) for snapshot-restore logic applied system-wide.
  • Update any sys.databases queries used in automation to filter out database_id <= 4 (system databases).
  • Re-deploy the corrected script and re-run the job manually to confirm Error 3139 no longer appears.

Step 4: Validate SQL Server Service Account Permissions

  • Ensure the service account running SQL Server has appropriate NTFS permissions on the backup/restore directory (e.g., C:\SQLBackups\).
  • Open Services.msc, locate SQL Server (MSSQLSERVER), and confirm the logon account matches the one granted file system access.

Alternative or Verification Steps

  • After restoring master via full backup, verify the instance started correctly by checking SQL Server Error Log at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for successful recovery messages.
  • If snapshot-based point-in-time recovery is required, apply snapshots only to user databases and use master full/differential backups as the alternative recovery path for system-level consistency.