0% found this document useful (0 votes)
0 views3 pages

SQL Server Backup Guide

The SQL Server Backup Guide outlines the importance of backups for data protection and recovery, detailing three types of backups: full, differential, and transaction log backups. It also explains recovery models and provides SQL commands for backup and restore operations. Best practices include scheduling backups, using COPY_ONLY for ad-hoc backups, and regularly testing restore procedures.

Uploaded by

johndoepi1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views3 pages

SQL Server Backup Guide

The SQL Server Backup Guide outlines the importance of backups for data protection and recovery, detailing three types of backups: full, differential, and transaction log backups. It also explains recovery models and provides SQL commands for backup and restore operations. Best practices include scheduling backups, using COPY_ONLY for ad-hoc backups, and regularly testing restore procedures.

Uploaded by

johndoepi1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

SQL Server Backup Guide

1. Introduction

SQL Server backups are essential for data protection, disaster recovery, and compliance. Backups allow you

to restore data in case of corruption, deletion, or hardware failure.

2. Types of Backups

2.1 Full Backup

- Captures the entire database including part of the transaction log.

- Use regularly as the base for other backups.

SQL:

BACKUP DATABASE [YourDatabase]

TO DISK = 'D:\Backups\YourDatabase_FULL.bak'

WITH INIT, STATS = 10;

2.2 Differential Backup

- Captures only the data changed since the last full backup.

SQL:

BACKUP DATABASE [YourDatabase]

TO DISK = 'D:\Backups\YourDatabase_DIFF.bak'

WITH DIFFERENTIAL, STATS = 10;

2.3 Transaction Log Backup

- Captures all transactions since the last log backup.

- Needed for point-in-time recovery.

SQL:

BACKUP LOG [YourDatabase]


SQL Server Backup Guide

TO DISK = 'D:\Backups\YourDatabase_LOG.trn'

WITH STATS = 10;

3. Recovery Models

- Simple: No log backups possible.

- Full: Supports point-in-time recovery.

- Bulk-logged: Allows minimal logging for bulk operations.

Check recovery model:

SELECT name, recovery_model_desc

FROM sys.databases;

4. Restore Operations

4.1 Restore Full Backup

SQL:

RESTORE DATABASE [YourDatabase]

FROM DISK = 'D:\Backups\YourDatabase_FULL.bak'

WITH REPLACE, STATS = 10;

4.2 Restore Full + Differential

-- Restore full with NORECOVERY

RESTORE DATABASE [YourDatabase]

FROM DISK = 'D:\Backups\YourDatabase_FULL.bak'

WITH NORECOVERY;

-- Then restore differential

RESTORE DATABASE [YourDatabase]

FROM DISK = 'D:\Backups\YourDatabase_DIFF.bak'

WITH RECOVERY;
SQL Server Backup Guide

4.3 Restore Full + Log Backups

-- Restore full with NORECOVERY

RESTORE DATABASE [YourDatabase]

FROM DISK = 'D:\Backups\YourDatabase_FULL.bak'

WITH NORECOVERY;

-- Restore log backup

RESTORE LOG [YourDatabase]

FROM DISK = 'D:\Backups\YourDatabase_LOG.trn'

WITH RECOVERY;

5. Best Practices

- Schedule backups using SQL Agent.

- Use COPY_ONLY for ad-hoc backups.

- Test restore procedures regularly.

- Store backups offsite or in cloud storage.

You might also like