Troubleshooting Guide: Error 3179 – System Database Cannot Be Moved by RESTORE
Why This Error Happens
Error 3179 occurs when SQL Server 2025 attempts to RESTORE a system database (such as master, model, or msdb) to a new file location, but the operation is blocked because system databases have special restrictions compared to user databases. This typically happens because the RESTORE command was issued with incorrect syntax (missing MOVE clauses for both the data and log files), the target path does not exist or lacks proper permissions, or the SQL Server service account cannot access the new destination folder. Additionally, system databases generally require the instance to be started in single-user mode via startup parameters before relocation is permitted.
Step-by-Step Resolution Guide
Step 1: Stop the SQL Server Service and Start in Single-User Mode
- Open SQL Server Configuration Manager on Windows Server 2025 / Windows 11.
- Right-click the SQL Server instance, go to Properties > Startup Parameters, and add
-mto force single-user mode. - Restart the SQL Server service for the change to take effect.
- Verify only one connection (via SQLCMD) is made to avoid conflicts with the Dedicated Admin Connection (DAC).
Step 2: Verify and Prepare the Destination Folder
- Ensure the new target directory (e.g.,
D:\SQLData\System\) already exists; SQL Server will not auto-create folders during RESTORE. - Grant Full Control permissions on the destination folder to the SQL Server service account (e.g.,
NT Service\MSSQLSERVER). - Confirm there is no naming conflict with existing
.mdfor.ldffiles in the new location.
Step 3: Run the RESTORE Command with Explicit MOVE Clauses
- Connect via SQLCMD using the Dedicated Admin Connection:
sqlcmd -S servername -A. - Execute the restore using both logical and physical file mappings:
RESTORE DATABASE master
FROM DISK = 'D:\Backup\master.bak'
WITH MOVE 'master' TO 'D:\SQLData\System\master.mdf',
MOVE 'mastlog' TO 'D:\SQLData\System\mastlog.ldf',
REPLACE;
- Ensure logical file names match those in the backup (
RESTORE FILELISTONLY FROM DISK = 'path'to confirm).
Step 4: Update Startup Parameters to Point to New File Locations
- If restoring
master, update the-d(data file) and-l(log file) startup parameters in SQL Server Configuration Manager to reflect the new paths. - Remove the
-msingle-user flag once the restore completes successfully. - Restart the SQL Server service normally.
Alternative or Verification Steps
- Verify the fix by querying
sys.master_filesto confirm thephysical_namecolumn reflects the new file paths for the restored database. - If the error persists, use
ALTER DATABASE ... MODIFY FILEfor user databases (not applicable tomaster) as an alternative, or restore from a fresh backup with correctedMOVEsyntax after confirming folder permissions viaicacls D:\SQLData\System\.