SQL Server Backup & Restore

Backup and Restore Best Practices

Effective backup and restore strategies are critical for protecting your SQL Server data and ensuring business continuity. The guidelines below are distilled from Microsoft’s recommendations and real‑world experience.

1. Define Recovery Objectives

2. Choose Appropriate Backup Types

Backup TypeTypical UseFrequency
FullBase line, weekly or bi‑weeklyWeekly
DifferentialCaptures changes since last fullDaily
Transaction LogPoint‑in‑time recoveryEvery 15‑30 min (or continuous)
Copy‑OnlyAd‑hoc backups without breaking the sequenceAs needed

3. Implement a Backup Schedule

-- Example: Create a maintenance plan with T‑SQL
EXEC msdb.dbo.sp_add_job @job_name = N'DailyBackup';
EXEC msdb.dbo.sp_add_jobstep
    @job_name = N'DailyBackup',
    @step_name = N'FullBackup',
    @subsystem = N'TSQL',
    @command = N'BACKUP DATABASE [MyDB] TO DISK = N''D:\Backups\MyDB_Full_$(ESCAPE_SQUOTE(DATEADD(day,0,GETDATE()),'''')).bak'' WITH INIT, COMPRESSION';
EXEC msdb.dbo.sp_add_schedule
    @schedule_name = N'DailyMidnight',
    @freq_type = 4, -- daily
    @active_start_time = 000000;
EXEC msdb.dbo.sp_attach_schedule
    @job_name = N'DailyBackup',
    @schedule_name = N'DailyMidnight';

4. Store Backups Securely

5. Test Restores Regularly

Schedule monthly restore drills on a test server. Verify both full and point‑in‑time recoveries.

-- Restore to a point in time
RESTORE DATABASE MyDB
FROM DISK = 'D:\Backups\MyDB_Full_20240901.bak'
WITH NORECOVERY;
RESTORE LOG MyDB
FROM DISK = 'D:\Backups\MyDB_Log_20240901_1200.trn'
WITH STOPAT = '2024-09-01 11:45:00', RECOVERY;

6. Automate Monitoring & Alerts

7. Document Your Strategy

Maintain a living document that includes:

Following these best practices helps you meet compliance requirements and minimizes data‑loss risk.