A backup you never tested is only a hope. This guide explains the recovery models (SIMPLE, FULL and BULK_LOGGED), shows how to take full, differential and transaction log backups, how to restore a database step by step with NORECOVERY and RECOVERY, and how to go back to one exact minute with STOPAT.
Part of the SQL Server for Beginners series. This article is the written version of lesson 12 of the Bigland Network video course, with the same sample data. The results shown were worked out by hand from that data, so run every example on a test database, not on production data.
Watch lesson 12 as a video or open it on YouTube. The written lesson below follows the same steps and the same sample data.
Contents
- 1. Why backups matter
- 2. The three recovery models
- 3. Full backup and its options
- 4. Differential and log backups
- 5. A simple backup plan
- 6. Verify a backup file
- 7. Restore a database
- 8. Restore a chain and point in time recovery
- 9. Backup history and where to keep backups
- 10. Mistakes and best practices
- 11. Practice
1. Why backups matter
- Mistakes: someone runs
DELETEwithout aWHEREclause. - Failures: a disk or a whole server dies.
- Attacks: ransomware or a bad update.
- The rule: no tested backup means no safety.
2. The three recovery models
Every database has a recovery model. It decides how the transaction log is kept.
| Model | Meaning |
|---|---|
| SIMPLE | No log backups. You can lose all work since the last backup. |
| FULL | Log backups allowed. You can restore to any minute. |
| BULK_LOGGED | Like FULL, but big loads are logged lightly |
For real company data, FULL is the usual choice. Check and change the model like this:
SELECT name, recovery_model_desc
FROM sys.databases
WHERE name = 'CompanyDB';
ALTER DATABASE CompanyDB
SET RECOVERY FULL;
| name | recovery_model_desc |
|---|---|
| CompanyDB | FULL |
After you switch to FULL, take a full backup. The log backups start working only after that.
3. Full backup and its options
BACKUP DATABASE CompanyDB
TO DISK = 'D:\Backup\CompanyDB_full.bak'
WITH COMPRESSION, CHECKSUM, INIT;
- A full backup copies the whole database. It is the base of every restore.
COMPRESSIONmakes the file smaller,CHECKSUMdetects damage early,INIToverwrites the old file with the same name.
4. Differential and log backups
BACKUP DATABASE CompanyDB
TO DISK = 'D:\Backup\CompanyDB_diff.bak'
WITH DIFFERENTIAL;
BACKUP LOG CompanyDB
TO DISK = 'D:\Backup\CompanyDB_log1.trn';
- A differential backup saves only what changed since the last full backup. It is smaller and faster.
- A log backup needs the FULL recovery model. It saves every change since the previous log backup and lets SQL Server reuse the log file. Without log backups, the log keeps growing.
5. A simple backup plan
| When | Backup |
|---|---|
| Sunday night | One full backup |
| Every night | One differential backup |
| Every 15 minutes | A log backup, all day |
| Result | You lose 15 minutes of work at most |
6. Verify a backup file
RESTORE VERIFYONLY
FROM DISK = 'D:\Backup\CompanyDB_full.bak'
WITH CHECKSUM;
SQL Server answers that the backup set on the file is valid. This checks the file only. Only a real restore proves that you can restore.
7. Restore a database
A disaster: someone forgets the WHERE clause.
DELETE FROM Employees;
SELECT COUNT(*) AS Employees FROM Employees;
| Employees |
|---|
| 0 |
All six employees are gone. Restore the full backup. Switch to master first, because you cannot restore a database that you are using:
USE master;
GO
RESTORE DATABASE CompanyDB
FROM DISK = 'D:\Backup\CompanyDB_full.bak'
WITH REPLACE;
SELECT COUNT(*) AS Employees FROM CompanyDB.dbo.Employees;
| Employees |
|---|
| 6 |
Be careful with REPLACE: it overwrites the existing database.
8. Restore a chain and point in time recovery
Often you need more than one file. Use NORECOVERY on every file except the last, which gets RECOVERY:
RESTORE DATABASE CompanyDB
FROM DISK = 'D:\Backup\CompanyDB_full.bak'
WITH NORECOVERY, REPLACE;
RESTORE DATABASE CompanyDB
FROM DISK = 'D:\Backup\CompanyDB_diff.bak'
WITH NORECOVERY;
RESTORE LOG CompanyDB
FROM DISK = 'D:\Backup\CompanyDB_log1.trn'
WITH NORECOVERY;
RESTORE DATABASE CompanyDB WITH RECOVERY;
While NORECOVERY is active, the database stays in the Restoring state. A very common mistake is to forget the last step, WITH RECOVERY.
To go back to one exact minute, restore the log with STOPAT:
RESTORE LOG CompanyDB
FROM DISK = 'D:\Backup\CompanyDB_log1.trn'
WITH STOPAT = '2026-11-10 09:29:00',
RECOVERY;
This needs the FULL recovery model and a complete chain of log backups.
9. Backup history and where to keep backups
SELECT TOP 3
CASE type WHEN 'D' THEN 'Full'
WHEN 'I' THEN 'Differential'
WHEN 'L' THEN 'Log' END AS BackupType,
backup_finish_date AS Finished
FROM msdb.dbo.backupset
WHERE database_name = 'CompanyDB'
ORDER BY backup_finish_date DESC;
| BackupType | Finished |
|---|---|
| Log | 2026-11-10 08:15 |
| Log | 2026-11-10 08:00 |
| Differential | 2026-11-10 01:00 |
Keep copies by the 3-2-1 rule: three copies of your data, on two different kinds of storage, and one copy in another place or in the cloud. Restore on another server every month to test.
10. Common mistakes and best practices
- Backups never tested with a real restore.
- FULL recovery model but no log backups, so the log grows.
- Backup files saved on the same disk as the database.
- Using
WITH REPLACEwithout thinking. - Forgetting
WITH RECOVERYat the end of a restore. - Best practice: choose the model from your business need, use
COMPRESSIONandCHECKSUM, automate the jobs (SQL Server Agent jobs), keep copies elsewhere, practice a restore and write the steps down, and watch the backup history for failed jobs. See also How to Back Up and Restore a SQL Server Database with T-SQL.
11. Practice
- Check the recovery model of CompanyDB, then set it to FULL.
- Make a compressed full backup with CHECKSUM, then a log backup.
- Restore the full backup and the log backup, and bring the database online.
SELECT name, recovery_model_desc
FROM sys.databases WHERE name = 'CompanyDB'; -- SIMPLE in our example
ALTER DATABASE CompanyDB SET RECOVERY FULL;
BACKUP DATABASE CompanyDB
TO DISK = 'D:\Backup\CompanyDB_full.bak'
WITH COMPRESSION, CHECKSUM, INIT;
BACKUP LOG CompanyDB
TO DISK = 'D:\Backup\CompanyDB_log1.trn';
RESTORE DATABASE CompanyDB
FROM DISK = 'D:\Backup\CompanyDB_full.bak'
WITH NORECOVERY, REPLACE;
RESTORE LOG CompanyDB
FROM DISK = 'D:\Backup\CompanyDB_log1.trn'
WITH RECOVERY;
Frequently asked questions
Which recovery model should I use?
Use FULL for data you cannot afford to lose, together with regular log backups. SIMPLE is fine for test data that you can rebuild.
What is the difference between NORECOVERY and RECOVERY?
NORECOVERY means more backup files are coming, so the database stays in the Restoring state. RECOVERY finishes the restore and brings the database online.
Does RESTORE VERIFYONLY prove my backup works?
No. It checks that the file is readable and valid. Only a real restore on another server proves that you can recover.
What to learn next
The next lesson covers query performance tuning. Previous lesson: Lesson 11: Security: Logins, Users and Roles.
The whole series
- Lesson 1: SELECT, WHERE and ORDER BY
- Lesson 2: JOINs
- Lesson 3: GROUP BY, HAVING and Subqueries
- Lesson 4: INSERT, UPDATE, DELETE and Transactions
- Lesson 5: CREATE TABLE, Data Types and Constraints
- Lesson 6: Indexes, Views and Stored Procedures
- Lesson 7: CTEs and Window Functions
- Lesson 8: Built-in Functions
- Lesson 9: Functions, Temp Tables and Table Variables
- Lesson 10: Triggers and Audit Tables
- Lesson 11: Security: Logins, Users and Roles
- Lesson 12: Backup, Restore and Recovery Models (this article)
- Lesson 13: Query Performance Tuning
- Lesson 14: SQL Server Agent Jobs and Maintenance
- Lesson 15: Encryption and Auditing Basics
- Lesson 16: Working with JSON
- Lesson 17: Temporal Tables and Row History
- Lesson 18: Partitioning and Large Tables
- lesson 19: Full Text Search
- lesson 20: Query Store and Slow Queries
Sources and further reading
- Microsoft Learn, Transact-SQL reference (Database Engine), on learn.microsoft.com: the official syntax for the statements used here.
- Microsoft Learn, SQL Server documentation, for SQL Server Management Studio (SSMS) and the sample concepts.
More tutorials like this
Msg 208 Invalid Object Name in SQL Server: Causes and Fix
Fix SQL Server Msg 208 Invalid object name: check the spelling, the database and the schema, with real SSMS examples and scripts to find…
SQL Server Query Store Tutorial: Find Slow Queries, Compare Plans and Force a Plan
Turn on Query Store, find the most expensive queries with the sys.query_store views and the SSMS reports, compare the plans of one query and…
SQL Server Full Text Search Tutorial: CONTAINS, FORMSOF and CONTAINSTABLE
Search words inside text columns fast: create a full text catalog and index, use CONTAINS, word forms, phrases and rank the best matches with…
