A backup you have never restored is only a hope. This guide shows the T-SQL for full, differential and transaction log backups, how to check that a backup is readable, and how to restore it safely, including to a different name and folder so you can test without touching the original database.
The three backup types
| Type | What it contains | Needs |
|---|---|---|
| Full | The whole database at that moment | Nothing |
| Differential | Everything changed since the last full backup | A full backup first |
| Transaction log | All log records since the last log backup | FULL or BULK_LOGGED recovery model |
Check which recovery model each database uses:
SELECT name, recovery_model_desc FROM sys.databases;
If a production database is in SIMPLE recovery you cannot back up its log and you can only restore to the time of a full or differential backup. Switch to FULL if you need point-in-time recovery:
ALTER DATABASE SalesDB SET RECOVERY FULL;
After switching, take a new full backup, otherwise the log backups have no starting point.
Step 1: Take a full backup
BACKUP DATABASE SalesDB
TO DISK = N'D:\Backups\SalesDB_full.bak'
WITH INIT, COMPRESSION, CHECKSUM, STATS = 10;
CHECKSUMmakes SQL Server validate pages while it reads them, so silent corruption is caught.COMPRESSIONsaves a lot of space. Remove it on Express edition, which cannot create compressed backups.INIToverwrites the file if it exists. Use a new file name per backup in real life, for example with the date.
Step 2: Differential and log backups
BACKUP DATABASE SalesDB
TO DISK = N'D:\Backups\SalesDB_diff.bak'
WITH DIFFERENTIAL, COMPRESSION, CHECKSUM;
BACKUP LOG SalesDB
TO DISK = N'D:\Backups\SalesDB_log_01.trn'
WITH COMPRESSION, CHECKSUM;
A typical schedule is one full backup per week, a differential every night and a log backup every 15 minutes, which means you lose at most 15 minutes of data.
Step 3: Verify the backup
RESTORE VERIFYONLY
FROM DISK = N'D:\Backups\SalesDB_full.bak'
WITH CHECKSUM;
This confirms the file is complete and readable. It does not prove the data is usable, so you still need a real test restore (next step) from time to time.
Step 4: Restore to a new database (safe test)
First list the logical file names inside the backup:
RESTORE FILELISTONLY
FROM DISK = N'D:\Backups\SalesDB_full.bak';
Then restore under a new name and move the files so they do not collide with the originals:
RESTORE DATABASE SalesDB_Copy
FROM DISK = N'D:\Backups\SalesDB_full.bak'
WITH MOVE N'SalesDB' TO N'D:\Data\SalesDB_Copy.mdf',
MOVE N'SalesDB_log' TO N'D:\Data\SalesDB_Copy_log.ldf',
RECOVERY, STATS = 10;
Replace the two logical names with the ones returned by FILELISTONLY. Run a few queries against SalesDB_Copy and you know the backup is good.
Step 5: Restore a full chain (full + differential + log)
Use NORECOVERY on every step except the last, so the database stays ready to accept more backups:
RESTORE DATABASE SalesDB_Copy FROM DISK = N'D:\Backups\SalesDB_full.bak'
WITH NORECOVERY, MOVE N'SalesDB' TO N'D:\Data\SalesDB_Copy.mdf', MOVE N'SalesDB_log' TO N'D:\Data\SalesDB_Copy_log.ldf';
RESTORE DATABASE SalesDB_Copy FROM DISK = N'D:\Backups\SalesDB_diff.bak'
WITH NORECOVERY;
RESTORE LOG SalesDB_Copy FROM DISK = N'D:\Backups\SalesDB_log_01.trn'
WITH RECOVERY, STOPAT = '2026-10-28 14:30:00';
STOPAT is the point-in-time feature: the database comes back exactly as it was at that moment. Without RECOVERY on the last step the database stays in the “Restoring” state.
See your backup history
SELECT TOP 10 database_name, type, backup_start_date, backup_size / 1048576 AS size_mb
FROM msdb.dbo.backupset
ORDER BY backup_start_date DESC;
Type D is full, I is differential and L is log.
Rules that save you
- Keep copies on a different disk or machine, ideally off-site as well.
- Do a test restore every month and write down how long it took.
- Monitor that backup jobs actually ran. A job that has silently failed for weeks is the classic disaster.
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…
