Why This Error Happens
Error 4352 occurs when SQL Server detects a gap or mismatch in the LSN (Log Sequence Number) chain during a restore sequence, typically because the transaction log backup being applied predates the most recent full or differential backup already restored. This commonly happens when log backups are skipped, deleted, or taken out of order, or when a backup chain is restored from a different point-in-time than the data file’s current recovery state. It can also occur if the backup device contains stale files from a previous log backup job that was not properly sequenced with the current full backup.
Step-by-Step Resolution Guide
Step 1: Verify the Backup Chain Sequence
- Query
msdb.dbo.backupsetto list all backups for the database, ordered bybackup_start_date. - Confirm the
first_lsnandlast_lsnvalues are contiguous between the full/differential backup and the log backups you intend to restore. - Run:
SELECT backup_start_date, type, first_lsn, last_lsn, database_backup_lsn FROM msdb.dbo.backupset WHERE database_name = 'YourDB' ORDER BY backup_start_date;
Step 2: Take a Fresh Log Backup Before Restoring
- If the existing log backup file is “too old” (its LSN predates the last restored full/differential backup), take a new transaction log backup immediately using
BACKUP LOG YourDB TO DISK = 'C:\Backups\YourDB_log_new.trn'; - Ensure the database is still in
RESTORINGstate (do not runRESTORE WITH RECOVERYprematurely) so the log chain remains intact. - Use this newly created log backup file instead of the outdated one in your
RESTORE LOGstatement.
Step 3: Restart the Restore Sequence from a Valid Full Backup
- If the log chain is broken beyond repair, restore a new full backup taken after the current point, using
RESTORE DATABASE YourDB FROM DISK = 'C:\Backups\YourDB_full.bak' WITH NORECOVERY; - Reapply differential backups (if any) with
WITH NORECOVERY. - Apply only log backups whose
first_lsnmatches thelast_lsnof the previously restored backup, in strict chronological order.
Step 4: Check Backup Job Scheduling and Retention
- Open SQL Server Agent (in SSMS under SQL Server Agent > Jobs) and confirm log backup jobs run on a consistent schedule without gaps.
- On Windows Server 2025, verify the backup folder (e.g.,
C:\Backups\Logs\) isn’t being purged by a retention/cleanup task before the log backups are applied. - Adjust the job schedule or file retention policy in Task Scheduler or your backup software to prevent future LSN gaps.
Alternative or Verification Steps
- After completing the restore sequence, run
RESTORE DATABASE YourDB WITH RECOVERYand confirm the database comes online without errors; checksys.databasesforstate_desc = 'ONLINE'. - If log backups are consistently out of sync, consider switching to a maintenance plan or Ola Hallengren’s backup scripts to enforce a strict, uninterrupted full → differential → log backup chain.