Book a health check
← All articles
SQL Server · Backup · Disaster recovery

Your backup job is green. Can you restore it?

RESTORE VERIFYONLY says the backup set is valid. It does not say the database inside is healthy. A practical routine to prove your backups work, with the scripts.

The backup job has been green every night for three years. Then a disk controller starts writing garbage, a page gets corrupted, and you need to restore. The restore works, but the corruption is in the backup too. It has been there for weeks, and so has every backup since.

A green job proves that a file was written. It does not prove that you can get your data back.

What RESTORE VERIFYONLY really checks

RESTORE VERIFYONLY reads the backup and checks that the backup set is complete and readable. If the backup was taken WITH CHECKSUM, it can also recheck the page checksums stored in it.

What it does not do is check the database itself: allocation structures, indexes that disagree with their tables, logical corruption. A database with a corrupt page produces a perfectly valid backup set.

So verification is a good first step, not the proof. Here is the routine I recommend.

1. Make sure pages carry checksums

Without page checksums, SQL Server cannot detect most on-disk corruption at all.

SELECT name, page_verify_option_desc
FROM sys.databases
WHERE page_verify_option_desc <> 'CHECKSUM';

-- fix it
ALTER DATABASE Sales SET PAGE_VERIFY CHECKSUM;

Existing pages only get a checksum when they are next written, so this protects you more and more over time. Databases upgraded from very old versions are the usual suspects.

2. Take every backup WITH CHECKSUM

With CHECKSUM, the backup verifies every page checksum as it reads it and fails instead of silently copying a bad page. Make it the instance default so no job can forget it:

EXEC sp_configure 'backup checksum default', 1;
RECONFIGURE;

Then check the history. Any recent backup without checksums deserves a look:

SELECT TOP (50)
       database_name, type, backup_finish_date,
       has_backup_checksums, is_damaged
FROM msdb.dbo.backupset
ORDER BY backup_finish_date DESC;

3. Look at the suspect pages table

SQL Server records pages that failed a checksum or a read here. On a healthy system it is empty.

SELECT * FROM msdb.dbo.suspect_pages;

4. Restore it for real, then run CHECKDB

This is the only test that proves the backup. On a test server, on a schedule, restore the latest full backup and check it:

RESTORE FILELISTONLY FROM DISK = N'\\backupshare\Sales\Sales_FULL.bak';

RESTORE DATABASE Sales_RestoreTest
FROM DISK = N'\\backupshare\Sales\Sales_FULL.bak'
WITH MOVE N'Sales'     TO N'D:\RestoreTest\Sales_RestoreTest.mdf',
     MOVE N'Sales_log' TO N'L:\RestoreTest\Sales_RestoreTest.ldf',
     CHECKSUM, REPLACE, STATS = 10;

DBCC CHECKDB (Sales_RestoreTest) WITH NO_INFOMSGS, ALL_ERRORMSGS;

Use RESTORE FILELISTONLY first to get the logical file names. If you use point-in-time recovery, restore the log backups too: a broken log chain only shows up when you try to apply it.

A bonus: a clean CHECKDB on the restored copy tells you the data in production was healthy at backup time. On very large databases, that lets you run lighter checks in production, for example PHYSICAL_ONLY, and keep the full check on the copy.

If you use PowerShell, the free dbatools module automates the whole cycle with Test-DbaLastBackup: restore, CHECKDB, drop, and a report.

5. Time it

Write down how long the restore took. That number is your real recovery time, whatever the SLA says. If the business expects the system back in one hour and the restore takes three, it is much better to find out on a Tuesday afternoon than during an outage.

The checklist

  • Page verification is CHECKSUM on every database.
  • Every backup runs WITH CHECKSUM, and it is the instance default.
  • msdb.dbo.suspect_pages is empty, and someone is alerted if it is not.
  • A real restore plus DBCC CHECKDB runs on a schedule, on another server.
  • The restore time is measured and matches what the business expects.

A backup is a hope. A tested restore is a guarantee. Backup and restore are one of the areas I go through line by line in every health check.

Want a second pair of eyes on your servers?

I review SQL Server and PostgreSQL instances for companies across Europe: fixed price, written findings, scripts included.

Or start on your own: run the free SQL Server check-up script →

Vincenzo Petrucci
About the author

Vincenzo Petrucci is a senior DBA and T-SQL developer with more than twenty years on production SQL Server and PostgreSQL systems for banks, insurers, telecom operators and commodity traders. He runs Pacific IT Solutions.

More about Vincenzo →

More articles

Same query, same index: seek on one SQL Server, scan on anotherA VARCHAR column, an NVARCHAR parameter and the wrong collation. Why the same application flies in test and crawls in production, and how to fix it without touching the schema.NOLOCK can count the same row twiceDirty reads are the problem everyone knows. Missing and duplicated rows are the one that ends up in finance reports. What really happens under READ UNCOMMITTED, and what to use instead.