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

Troubleshooting Guide: SQL Server Error 4331 – Inconsistent Restore Points

Why This Error Happens

Error 4331 occurs when a database restore sequence (full, differential, and transaction log backups) is applied out of order or with mismatched LSNs (Log Sequence Numbers), leaving the data and log files in two different points in time. This commonly happens when a differential backup is restored against the wrong full backup baseline, or when log backups are applied without the NORECOVERY option during intermediate steps. File-level corruption or manually copied .mdf/.ldf files from different backup sets can also trigger this inconsistency.

Step-by-Step Resolution Guide

Step 1: Verify the Backup Chain Integrity

  • Run RESTORE HEADERONLY FROM DISK = 'C:\Backups\YourDB.bak' to inspect the LSN values (FirstLSN, LastLSN, CheckpointLSN) of each backup file.
  • Confirm that the Full backup’s DatabaseBackupLSN matches the baseline expected by your Differential and Log backups.
  • Discard any backup files where the BackupStartDate does not align sequentially.

Step 2: Restart the Restore Sequence from a Clean Baseline

  • Drop the partially restored database if it exists: DROP DATABASE YourDB;
  • Restore the Full backup first with NORECOVERY:
  RESTORE DATABASE YourDB 
  FROM DISK = 'C:\Backups\YourDB_Full.bak' 
  WITH NORECOVERY, MOVE 'YourDB' TO 'D:\SQLData\YourDB.mdf', 
  MOVE 'YourDB_log' TO 'D:\SQLLogs\YourDB_log.ldf';
  • Apply the Differential backup (if used) with NORECOVERY, then apply Transaction Log backups in exact chronological order.

Step 3: Finalize Recovery and Validate File Consistency

  • Once the last log backup is applied, run the final restore command with WITH RECOVERY to bring the database online.
  • Check sys.master_files to ensure the state_desc for both data and log files shows ONLINE.
  • If Windows Server 2025 File History or VSS snapshots were used instead of native SQL backups, ensure the snapshot captured both .mdf and .ldf files in the exact same transaction, as asynchronous disk snapshots are a frequent cause of this error.

Step 4: Check for Underlying Storage/Permission Issues

  • Verify the SQL Server service account (NT Service\MSSQLSERVER) has full control permissions on the D:\SQLData and D:\SQLLogs directories.
  • Use Get-Acl in PowerShell to audit folder permissions if the restore fails due to access denial during the file-move phase.

Alternative or Verification Steps

  • Verification: Run DBCC CHECKDB('YourDB') WITH NO_INFOMSGS, ALL_ERRORMSGS; after recovery to confirm there is no lingering physical corruption from the inconsistent restore.
  • Alternative: If the backup chain is unrecoverable, restore the Full backup alone using WITH RECOVERY (accepting data loss up to that point) rather than attempting to force a broken differential/log chain.