SQL Server Backup and Restore

SQL Server Backup and Restore

December 2nd, 2026
60
5:00 Minutes

You open up your laptop on a Monday morning only to see a message from a developer. Some delete statement ran on a production table and it did not have a WHERE clause and hundreds of customer records are now lost. Can you get those records back?

Of course, the answer would be yes if you do have a working backup. If you don't, the costs would be very hefty. In fact, any type of incident - hardware failures, human errors, corruption, ransomware - can and will happen at any moment with a database. SQL Server backup and restore can be your best possible safety net against any of those problems.

In this blog, we will explain to you what SQL Server backup and restore are all about, the backup types and recovery models that you have in place and how exactly to perform a backup and restore process with SSMS and T-SQL. We will also tell you all about point-in-time recovery along with several possible mistakes you might make and how to avoid them.

Also Explore: SQL Server vs MySQL

What Is SQL Server Backup and Restore?

SQL Server Backup and Restore is an in built process of copying database data and transaction logs to protect against data loss and then recovering those copies after a failure or corruption. It serves as a main pillar of database disaster recovery and data protection.

Regular backups let you restore a database to an earlier state. This reduces the risk of losing important information.

Here are the key terms you will see in this guide:

  • Backup: A copy of data or log records, saved to a disk, tape or cloud storage.
  • Restore: The process of copying data from a backup back into a database.
  • Recovery: The final step that brings the restored database online in a consistent state.
  • RPO (Recovery Point Objective): The amount of data your business can afford to lose.
  • RTO (Recovery Time Objective): The time your business can wait before the database is available again.

Your RPO and RTO decide your backup plan. A bank that can lose zero minutes of data needs a different plan from a small blog that can lose a day.

What Are the Different Types of SQL Server Backups?

SQL Server supports five main backup types. Each one answers a different need.

Backup typeWhat it containsBest for
FullThe entire databaseThe base of every backup plan
DifferentialChanges since the last full backupFaster daily backups
Transaction logLog records since the last log backupPoint-in-time recovery
Copy-onlyA full or log copy outside the normal chainAd hoc copies for testing
File and filegroupSelected files or filegroupsVery large databases

1. Full Database Backup

A full backup copies all the data in the database. It also copies enough of the transaction log to bring the database to a consistent state on restore. Every other backup type depends on it.

BACKUP DATABASE SalesDB
TO DISK = N'D:\SQLBackups\SalesDB_Full.bak'
WITH COMPRESSION, CHECKSUM, STATS = 10;

A full backup of a large database takes time and space. Most teams run it once a day or once a week.

2. Differential Database Backup

A differential backup copies only the data that changed since the last full backup. It is smaller and faster than a full backup. Each new differential grows larger until the next full backup resets it.

BACKUP DATABASE SalesDB
TO DISK = N'D:\SQLBackups\SalesDB_Diff.bak'
WITH DIFFERENTIAL, COMPRESSION, CHECKSUM;

To restore from a differential, you need the full backup first and then the latest differential.

3. Transaction Log Backup

A transaction log backup records every transaction since the previous log backup. It lets you restore a database to a specific moment. You can run it every few minutes to keep data loss very low.

BACKUP LOG SalesDB
TO DISK = N'D:\SQLBackups\SalesDB_Log.trn'
WITH COMPRESSION, CHECKSUM;

Two rules apply here. The database must use the Full or Bulk-logged recovery model. A full backup must also exist before the first log backup.

A tail-log backup is a special log backup. It captures the last records that no earlier log backup has saved. You take it just before a restore so you do not lose the most recent work.

4. Copy-Only Backup

A copy-only backup is a standalone copy. It does not change the backup chain. A copy-only full backup does not reset the differential base. A copy-only log backup does not truncate the log.

BACKUP DATABASE SalesDB
TO DISK = N'D:\SQLBackups\SalesDB_CopyOnly.bak'
WITH COPY_ONLY, COMPRESSION;

Use it when you need a quick copy for a test server and do not want to disturb your schedule.

5. File and Filegroup Backup

A file or filegroup backup copies only part of a database. It suits very large databases where a full backup takes too long. You can back up one filegroup each night and still protect the whole database.

BACKUP DATABASE SalesDB
FILEGROUP = N'PRIMARY'
TO DISK = N'D:\SQLBackups\SalesDB_Primary.bak';

This method needs more planning. You must keep transaction log backups so you can bring all files to the same point in time.

Read Also: How to Install Microsoft SQL Server?

What Are SQL Server Recovery Models?

A recovery model controls how SQL Server logs transactions. It also decides which backups you can take and which restores you can run. Every database uses one of three models.

FeatureSimpleFullBulk-logged
Log backupsNot supportedSupportedSupported
Point-in-time restoreNoYesLimited
Log managementSQL Server clears the log automaticallyYou must back up the log to clear itYou must back up the log to clear it
Data loss riskEverything since the last backupVery lowLow, but higher during bulk operations
Best forTest and developmentProduction systemsShort bulk loads

Simple: SQL Server clears the log at each checkpoint. You can restore only to your last full or differential backup. Any work after that is lost.

Full: SQL Server retains transaction log records until they are eligible for truncation. Log backups normally allow inactive log records to be reused, subject to other factors. You can restore to a specific point in time covered by your log backups, provided the required backup chain is intact. Most production databases use this model.

Bulk-logged: This model logs bulk operations, such as BULK INSERT, with minimal detail. It saves log space. You cannot restore to a point in time inside a log backup that holds bulk changes.

Check the current model of every database with this query:

SELECT name, recovery_model_desc
FROM sys.databases;

Change the model with ALTER DATABASE:’

ALTER DATABASE SalesDB SET RECOVERY FULL;

A new database copies its recovery model from the model system database. After you switch from Simple to Full, take a full backup right away. The log chain starts only after that backup.

If you are not sure which model fits, choose Full for production and Simple for test systems.

Also Read: MongoDB vs MySQL: Understanding Key Differences

How to Back Up a SQL Server Database

You need the right permissions first. Membership in the sysadmin server role, the db_owner role or the db_backupoperator role is enough. The SQL Server service account also needs write access to the backup folder.

Back Up a Database Using SSMS

  1. Open SQL Server Management Studio (SSMS) and connect to your instance.
  2. Expand Databases in Object Explorer.
  3. Right-click your database and choose Tasks, then Back Up.
  4. Select the Backup type: Full, Differential or Transaction Log.
  5. Under Destination, click Add and choose a file path with a .bak extension.
  6. Open the Media Options page and select Verify backup when finished.
  7. Click OK. SSMS shows a success message when the backup ends.

Back Up a Database Using T-SQL

T-SQL gives you more control and works well in scripts and scheduled jobs. Use the BACKUP DATABASE command for full and differential backups, and BACKUP LOG for log backups. The earlier examples show each form.

Add these options when they fit your needs:

  • COMPRESSION reduces file size and often shortens backup time.
  • CHECKSUM checks pages for damage while SQL Server writes the backup.
  • INIT overwrites old backups in the file instead of appending.
  • STATS = 10 shows progress every 10 percent.

Verify Your Backup

A backup that you never check is only a hope. Run this command to confirm that SQL Server can read the file:

RESTORE VERIFYONLY
FROM DISK = N'D:\SQLBackups\SalesDB_Full.bak'
WITH CHECKSUM;

You can also read your backup history from the msdb database:

SELECT TOP 10
database_name,
type,
backup_start_date,
backup_finish_date
FROM msdb.dbo.backupset
ORDER BY backup_finish_date DESC;

In the type column, D means full, I means differential and L means log.

Schedule Backups Automatically

Create a SQL Server Agent job for each backup type. A common schedule looks like this:

BackupFrequency
FullWeekly, on Sunday night
DifferentialDaily, at night
Transaction logEvery 15 minutes

SQL Server Express does not include SQL Server Agent. On Express, you can run a T-SQL script with sqlcmd and schedule it in Windows Task Scheduler.

How to Restore a SQL Server Database

A restore copies data from backup files into a database. Then SQL Server runs recovery to bring the database online. Follow the right order. You restore the full backup first, then the latest differential, and then the log backups.

Restore a Database Using SSMS

  1. Open SSMS and connect to your instance.
  2. Right-click Databases and choose Restore Database.
  3. Select Device as the source and click the ellipsis (...) button.
  4. Click Add, pick your .bak file and click OK.
  5. Check the list of backup sets that SSMS shows. Keep the sets you need selected.
  6. Open the Files page if you need to change the file locations.
  7. Open the Options page. Select Overwrite the existing database only when you want to replace a live database.
  8. Click OK.

Restore a Database Using T-SQL

Use the RESTORE DATABASE command for a simple full restore. Use WITH REPLACE only when you intentionally want to overwrite an existing database, after verifying the target database and backup.

RESTORE DATABASE SalesDB
FROM DISK = N'D:\SQLBackups\SalesDB_Full.bak'
WITH REPLACE, RECOVERY, STATS = 10;

When you restore to a new server, the drive paths may differ. First, list the files inside the backup:

RESTORE FILELISTONLY
FROM DISK = N'D:\SQLBackups\SalesDB_Full.bak';

Then use the MOVE option to place each file in a new location:

RESTORE DATABASE SalesDB_Copy
FROM DISK = N'D:\SQLBackups\SalesDB_Full.bak'
WITH MOVE N'SalesDB' TO N'E:\Data\SalesDB_Copy.mdf',
MOVE N'SalesDB_log' TO N'F:\Logs\SalesDB_Copy_log.ldf',
RECOVERY;

Understand RECOVERY, NORECOVERY and STANDBY

These three options decide what happens after each restore step.

OptionWhat it doesWhen to use it
RECOVERYBrings the database onlineOn the last restore step
NORECOVERYKeeps the database in a restoring stateWhen more backups are still to come
STANDBYKeeps the database read-only and ready for more restoresWhen you want to read data between restore steps

If you forget NORECOVERY on an early step, SQL Server brings the database online. You then cannot apply the next backup and must start over.

Restore a Full, Differential and Log Chain

RESTORE DATABASE SalesDB
FROM DISK = N'D:\SQLBackups\SalesDB_Full.bak'
WITH NORECOVERY, REPLACE;
RESTORE DATABASE SalesDB
FROM DISK = N'D:\SQLBackups\SalesDB_Diff.bak'
WITH NORECOVERY;
RESTORE LOG SalesDB
FROM DISK = N'D:\SQLBackups\SalesDB_Log.trn'
WITH RECOVERY;

Remember one rule about versions. You can restore a backup to the same SQL Server version or a newer one. You cannot restore it to an older version.

How to Restore a SQL Server Database to a Point in Time

A point-in-time restore returns a database to an exact moment before a problem happened. It is the best tool for accidental deletes and bad updates.

You need three things:

  • The database must use the Full recovery model (or Bulk-logged with no bulk changes in the target log).
  • You must have a full backup taken before the target time.
  • You must have an unbroken chain of log backups that covers the target time.

Suppose someone deleted rows at 2:35 PM on 27 November 2026. You want the database as it looked at 2:30 PM.

--- Step 1: Back up the tail of the transaction log
BACKUP LOG SalesDB
TO DISK = 'C:\Backups\SalesDB_Tail.trn'
WITH NORECOVERY, NO_TRUNCATE, STATS = 10;
GO
-- Step 2: Restore the full backup
RESTORE DATABASE SalesDB
FROM DISK = 'C:\Backups\SalesDB_Full.bak'
WITH NORECOVERY, REPLACE, STATS = 10;
GO
-- Step 3: Restore the latest differential backup
RESTORE DATABASE SalesDB
FROM DISK = 'C:\Backups\SalesDB_Diff.bak'
WITH NORECOVERY, STATS = 10;
GO
-- Step 4: Restore the first transaction log backup
RESTORE LOG SalesDB
FROM DISK = 'C:\Backups\SalesDB_Log_1.trn'
WITH NORECOVERY, STATS = 10;
GO
-- Step 5: Restore the next transaction log backup, if one exists
RESTORE LOG SalesDB
FROM DISK = 'C:\Backups\SalesDB_Log_2.trn'
WITH NORECOVERY, STATS = 10;
GO
-- Step 6: Restore the tail-log backup to the target time
RESTORE LOG SalesDB
FROM DISK = 'C:\Backups\SalesDB_Tail.trn'
WITH STOPAT = '2026-11-27 14:30:00',
RECOVERY,
STATS = 10;
GO

You can also use the SSMS Restore Database window. Click Timeline, choose Specific date and time and enter the target time. SSMS then builds the restore sequence for you.

Keep these points in mind:

  • If your target time is in the middle of the database's last log backup, restore the tail-log backup last and use STOPAT there.
  • Use STOPBEFOREMARK if you want to stop before a named transaction or LSN.
  • Test the restored data before you let users in. If the time is wrong, you can restart the restore from the full backup.

Common SQL Server Backup and Restore Errors and How to Fix Them

Every DBA sees these errors sooner or later. This table shows the most common ones.

ErrorCauseHow to fix it
Msg 3159: The tail of the log has not been backed upSome recent database changes have not been saved in a backup. Restoring now could cause data loss.Take a tail-log backup before restoring. If you do not need the remaining changes, use WITH REPLACE.
Msg 3101: Exclusive access could not be obtainedOther users or applications are connected to the database, so SQL Server cannot restore it.Disconnect other users, switch the database to SINGLE_USER mode, restore it, and then switch it back to MULTI_USER mode.
Msg 3201: Cannot open backup device (OS error 5)SQL Server cannot access the backup file because the path is incorrect or it lacks permission.Check the file path and give the SQL Server service account the required permissions to access the backup file.
Msg 3154: The backup set holds a backup of a different databaseThe backup belongs to a different database than the one you are trying to restore.Use WITH REPLACE if you want to overwrite the existing database, or restore the backup using a new database name.
Msg 3156: File cannot be restoredSQL Server cannot find the original database file location on the new server.Use RESTORE FILELISTONLY to check the database files and the MOVE option to specify a valid location.
Msg 3169: Backup is incompatible with this serverThe backup was created using a newer version of SQL Server than the one you are restoring it to.Restore the backup on the same or a newer SQL Server version.
Msg 4305: The log in this backup set begins at LSN... too recentAn earlier transaction log backup is missing, so SQL Server cannot restore the current log backup in the correct order.Find the missing log backup and restore all required log backups in the correct sequence.

Here is the fix for the exclusive access error:

ALTER DATABASE SalesDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
RESTORE DATABASE SalesDB
FROM DISK = N'D:\SQLBackups\SalesDB_Full.bak'
WITH REPLACE, RECOVERY;
ALTER DATABASE SalesDB SET MULTI_USER;

If SQL Server reports a damaged or unreadable backup file, run RESTORE VERIFYONLY and RESTORE HEADERONLY on it. If the file is truly corrupt, restore from your next older backup set.

SQL Server Backup and Restore Best Practices

Follow these habits to keep your data safe.

1. Define your RPO and RTO first: Your backup schedule must match what the business can afford to lose and to wait.

2. Follow the 3-2-1 rule: Keep three copies of your backups, on two types of media, with one copy off site or in the cloud.

3. Use the Full recovery model for production: It gives you point-in-time recovery. Remember to schedule log backups, or the log file will keep growing.

4. Combine backup types: A weekly full, a daily differential and frequent log backups balance speed and safety.

5. Use CHECKSUM and COMPRESSION: CHECKSUM finds damaged pages early. COMPRESSION saves space and time.

6. Test your restores regularly: Restore backups to a test server on a schedule. A backup counts only when you have proven it can restore.

7. Run DBCC CHECKDB: Check database integrity often. A backup of a corrupt database is a corrupt backup.

8. Encrypt your backups: Use native backup encryption and protect the certificate. Without that certificate, you cannot restore the backup.

BACKUP DATABASE SalesDB
TO DISK = N'D:\SQLBackups\SalesDB_Enc.bak'
WITH ENCRYPTION (ALGORITHM = AES_256, SERVER CERTIFICATE = BackupCert);

9. Back up the system databases: The master and msdb databases hold logins, jobs and backup history. Include them in your plan.

10. Store backups away from the data drive: A disk failure should never take out both the database and its backup.

11. Automate and monitor: Use SQL Server Agent jobs and alerts. Review msdb.dbo.backupset to confirm that every job runs.

12. Document your restore steps: Write a short runbook. In a real emergency, a clear checklist saves time.

SQL Server 2022 and later can also back up to S3-compatible object storage. Azure Blob Storage works as a backup target too. Cloud storage is a simple way to meet the off-site part of the 3-2-1 rule.

Wrapping Up

SQL Server backup and restore protects your data from hardware failures, human mistakes and corruption. You now know the five backup types, the three recovery models and the exact steps to back up and restore a database. You also know how to run a point-in-time restore and how to fix common errors.

To get started, check the recovery model of every database. Then set up a full, differential and log backup schedule. Finally, restore one backup to a test server this week. That single test tells you more about your safety than any setting.

FAQs

1. What is the difference between a full and a differential backup in SQL Server?

A full backup copies the entire database. A differential backup copies only the data that changed since the last full backup. Differentials are smaller and faster, but you need the full backup to restore them.

2. How often should I back up a SQL Server database?

It depends on your RPO. Many production systems take a weekly full backup, a daily differential backup and a log backup every 15 minutes. If you can lose less data, run log backups more often.

3. Can I restore a SQL Server backup to an older version?

No, SQL Server cannot restore a backup to a version older than the one that created it. You can restore it to the same or a newer version.

4. Can I back up a database while users are connected?

Yes. SQL Server backs up databases online, so users can keep working. Performance may drop a little during large backups so schedule them in quiet hours when you can.

5. What does WITH NORECOVERY do in a restore?

It leaves the database in a restoring state so you can apply more backups. You use it on every step except the last one. The last step uses RECOVERY to bring the database online

6. Can I do a point-in-time restore in the Simple recovery model?

No, the Simple model does not support log backups. Use the Full recovery model if you need point-in-time recovery.

About the Author
Vinay Agarwal | igmGuru
About the Author

Vinay Agarwal is a certified Microsoft technology professional with experience spanning Azure infrastructure, Microsoft 365, and productivity platforms. He works on cloud administration, identity management, and Microsoft certification pathways. Vinay follows Microsoft product and certification updates closely and helps prepare IT professionals for industry-recognized credentials.

Drop Us a Query
Fields marked * are mandatory
Recent Post
×

Your Shopping Cart


Your shopping cart is empty.