MSDN Documentation

Microsoft Developer Network

Backup and Restore Operations for SQL Server Database Engine

This section provides comprehensive guidance on backup and restore strategies for the SQL Server Database Engine. Effective backup and restore procedures are critical for data protection, disaster recovery, and maintaining the integrity of your databases.

Overview

SQL Server offers robust mechanisms for backing up and restoring databases. Understanding the different backup types, strategies, and restore options is essential for any SQL Server administrator.

Backup Types

Backup Strategies

Developing a sound backup strategy involves considering factors such as:

Common strategies include:

Restoring Databases

Restoring a database involves applying one or more backup files to recover the database to a specific point in time.

Key Concepts and Considerations

Syntax Examples

Full Backup

BACKUP DATABASE AdventureWorks2019
TO DISK = 'D:\Backups\AdventureWorks2019_Full.bak'
WITH NOINIT, NOUNLOAD, NAME = 'AdventureWorks2019 Full Backup', STATS = 10;

Differential Backup

BACKUP DATABASE AdventureWorks2019
TO DISK = 'D:\Backups\AdventureWorks2019_Diff.bak'
WITH DIFFERENTIAL, NOINIT, NOUNLOAD, NAME = 'AdventureWorks2019 Differential Backup', STATS = 10;

Transaction Log Backup

BACKUP LOG AdventureWorks2019
TO DISK = 'D:\Backups\AdventureWorks2019_Log.trn'
WITH NOINIT, NOUNLOAD, NAME = 'AdventureWorks2019 Log Backup', STATS = 10;

Restore Full Backup

RESTORE DATABASE AdventureWorks2019
FROM DISK = 'D:\Backups\AdventureWorks2019_Full.bak'
WITH NORECOVERY, REPLACE;

Restore Transaction Log Backup

RESTORE LOG AdventureWorks2019
FROM DISK = 'D:\Backups\AdventureWorks2019_Log.trn'
WITH NORECOVERY;

Finalize Restore (bring database online)

RESTORE DATABASE AdventureWorks2019 WITH RECOVERY;

Related Topics