Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

SQL Server Error 1412: Remote Copy Not Restored

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

SQL Server error 1412 means the remote copy of the database has not been restored to the point in time you are trying to recover to. In plain terms, you are trying to bring a secondary database online (or run a restore sequence) and SQL Server has detected that the log chain or the restore point on the remote copy is incomplete. The fix is to restore the missing log backups in the correct order, with NORECOVERY, until the remote copy reaches the required point. This guide walks through the practical steps to clear the error, with the checks and pitfalls that matter.

What You'll Need

  • Access to the primary and secondary SQL Server instances with sysadmin or db_owner rights.
  • The full backup and all subsequent transaction log backups for the database, in sequence.
  • The exact point in time or LSN you need to recover to (from the error message or your recovery plan).
  • Enough disk space on the secondary for the restored database and log files.
  • A maintenance window if the database is in use; restoring logs will take it offline.

Step-by-Step

  1. Read the full error message. Error 1412 usually appears with additional text naming the database and the restore point. Note the database name and any LSN or point-in-time reference. This tells you exactly which log backup is missing or out of order.
  2. Check the current restore state on the secondary. Connect to the secondary instance and run RESTORE HEADERONLY FROM DISK = 'path\to\backup.bak' for each backup file, or query msdb.dbo.backupset and msdb.dbo.backupmediafamily to list the backup history. Confirm the last restored LSN and the last LSN in the chain. The gap between them is what error 1412 is complaining about.
  3. Verify the log chain is unbroken. Every log backup must have a FirstLSN that matches the LastLSN of the previous backup. If a log backup is missing, you cannot bridge the gap; you will need a new full backup from the primary and a fresh restore sequence. Do not attempt to skip a missing log.
  4. Restore the missing log backups in order. On the secondary, run RESTORE LOG [YourDatabase] FROM DISK = 'path\to\log1.trn' WITH NORECOVERY, then repeat for each subsequent log file, always with NORECOVERY, until you reach the log that contains the recovery point. The NORECOVERY option keeps the database in restoring state so the next log can be applied.
  5. Apply the final log with the correct STOPAT or WITH RECOVERY. If you need a point-in-time recovery, use WITH STOPAT = 'YYYY-MM-DDTHH:MM:SS', RECOVERY on the last log. If you are bringing the secondary online as a standby, use WITH STANDBY = 'path\to\undo.ldf' instead. Using RECOVERY too early will end the log chain and cause further errors.
  6. Re-run the operation that raised error 1412. If the error came from an availability group or log shipping job, restart the job or resume the secondary. The remote copy should now be at the required point and the error should clear.
  7. Confirm the database is online and consistent. Run DBCC CHECKDB on the restored database and verify that the secondary is synchronized if you are using Always On or log shipping. Check the SQL Server error log for any new messages.

Common Mistakes

  • Using WITH RECOVERY on an intermediate log. This ends the restore sequence and makes any later log unusable. Always use NORECOVERY until the final log.
  • Restoring logs out of order. SQL Server will reject a log whose LSN does not follow the previous one. Sort your backup files by LastLSN, not by file name or date alone.
  • Assuming a full backup resets the chain. A full backup does start a new chain, but you must restore it with NORECOVERY before applying logs. Restoring it with RECOVERY and then trying to apply logs will fail.
  • Ignoring the tail-log backup. If the primary is still online and you need the latest point, take a tail-log backup first. Without it, the last transactions may be missing and error 1412 can persist.
  • Mixing backup sets from different databases or servers. Always verify the database name and server name in the backup header before restoring.

Tips

  • Script the restore sequence and test it on a non-production copy before running it on the secondary. A dry run catches LSN gaps early.
  • Keep a log of the last restored LSN for each database. This makes it quick to identify which backup is missing when error 1412 appears.
  • Use RESTORE VERIFYONLY on each backup file before restoring. It confirms the file is readable and not corrupt.
  • If you are using Always On availability groups, check the availability replica state and the availability group dashboard. Error 1412 often appears when a secondary replica cannot catch up because a log backup was skipped.
  • Schedule log backups frequently enough that the gap between backups is small. Smaller gaps mean less data to re-apply and fewer chances for a missing file.

Troubleshooting

If error 1412 persists after restoring the logs, check the following. First, confirm that the last log you restored actually contains the LSN referenced in the error. You can query msdb.dbo.backupset for the FirstLSN and LastLSN of each backup. Second, verify that the secondary database is still in RESTORING state; if it was accidentally brought online, you must start over with a full restore. Third, check for a broken log chain: if any log backup is missing or corrupt, you cannot continue. In that case, take a new full backup from the primary, restore it with NORECOVERY on the secondary, and then apply all subsequent log backups. Finally, if the error occurs during an availability group synchronization, remove the secondary database from the availability group, restore it fresh, and rejoin it. Always back up the tail of the log before making changes if data loss is a concern. If you are unsure which backup is missing, restore the chain to a new database name step by step and observe where it fails; that isolates the gap.

Frequently Asked Questions

What does error 1412 actually mean?

It means the remote copy of the database has not been restored to the point in time required by the operation. In practice, a log backup is missing or the restore sequence was ended too early with WITH RECOVERY.

Can I fix error 1412 without a full backup?

Only if the log chain is intact and you can supply the missing log backups in order. If a log is missing or corrupt, you need a new full backup and a fresh restore sequence.

Does this error affect the primary database?

No. Error 1412 relates to the secondary or remote copy. The primary database remains online and unaffected, but the secondary cannot be brought up to date until the restore is completed.

What is the difference between NORECOVERY and STANDBY?

NORECOVERY leaves the database inaccessible until the restore sequence is finished. STANDBY leaves it readable but read-only, and requires an undo file. Use NORECOVERY for a final restore and STANDBY for a warm standby you need to query.

Can error 1412 appear during log shipping?

Yes. If a log shipping copy or restore job fails or skips a file, the secondary can fall out of sync and raise error 1412. Check the log shipping history tables and reinitialize if the gap cannot be closed.

Is it safe to restore logs on a production secondary?

Restoring logs takes the database offline for the duration. Schedule it in a maintenance window and ensure you have a verified backup before starting.