Home » Blog » SQL Server » SQL Server Hot Backup and Cold Backup

SQL Server Hot Backup and Cold Backup

Neeraj Kumar
Published By Neeraj Kumar
Debasish Pramanik
Approved By Debasish Pramanik
Published On
Last Updated

Hot backups copy an online database while users work in it and offline copies capture its files while the database is closed. SQL Server takes online backups with the BACKUP DATABASE statement. Offline copies need the database detached or the service stopped. Three methods handle both options and the rescue case. Online backups suit daily protection and offline copies suit planned moves. Recovery software opens a damaged MDF file from a cold copy and exports its tables.

Your manager wants a backup of DepotDB before the weekend upgrade and the sales team still works in it. Hot backups avoid downtime while a clean file copy needs the database offline.

Search results explain both names and stop there. Few show the settings that make an online backup safe or the steps that make an offline copy usable.

This guide explains the difference between a hot backup and a cold backup, including the FORMAT option that makes older backups useless.

Microsoft states in the BACKUP reference that SQL Server uses an online backup process so a database backup works while the database is in use.

Hot vs Cold: Which Backup Fits Your Server?

Hot and cold are common trade names. Microsoft names the hot method an online backup process.

FeatureHotCold
Database stateOnlineOffline
User accessOpen during the backupClosed during the copy
OutputA BAK fileThe MDF and LDF files
Best forDaily protectionPlanned moves and upgrades
ToolsBACKUP DATABASEDetach and copy or a service stop

Use the table to match your situation to a method below.

3 Methods for Hot Backup and Cold Backup in SQL Server

Method #1 and Method #2 cost nothing. Method #3 starts from a damaged copy.

FeatureOnline CopyOffline CopyRecovery Software
PriceNo feeNo feeScan free and pay for export
Best forSystems that cannot stopPlanned downtimeDamaged MDF copies
NeedsBackup permissiondb_owner membershipWindows PC and an MDF copy
Main limitSome operations waitUsers lose accessTrial export limit

Method #1: Take a Hot Backup With BACKUP DATABASE (Free, Needs Backup Permission)

Microsoft documents the SSMS path in its full database backup guide. Right click the database and select Tasks and then Back Up. Per Microsoft Full is the default backup type.

Scripts suit scheduled hot backups. Add a page check and compression with this statement.

BACKUP DATABASE DepotDB
TO DISK = N'E:\Backups\DepotDB_Hot.bak'
WITH INIT, CHECKSUM, COMPRESSION;

Per Microsoft INSERT and UPDATE and DELETE statements work during a backup. File management and shrink operations cannot. BACKUP is also not allowed inside a transaction.

Default holders of the permission are sysadmin and db_owner and db_backupoperator members. Backup folders need access for the SQL Server startup account.

Microsoft states that the FORMAT option makes the existing contents of the volume invalid. Use INIT when you only want to overwrite the backup sets.

Method #2: Take a Cold Backup by Detaching the Files (Free, Needs Owner Rights)

Cold backups use files that no session opens. Detach affects one database and the rest of the server remains online. List every file first.

USE DepotDB;
GO
SELECT file_id, name, physical_name
FROM sys.database_files;

Microsoft calls for all files of the database before you detach and move. Detach next.

USE master;
GO
EXEC sp_detach_db N'DepotDB';

Per the detach a database guide detach deletes no files and needs db_owner membership. Active connections stop it. Copy the MDF file and the LDF file to a separate storage device and attach the database again.

CREATE DATABASE DepotDB
ON (FILENAME = N'D:\SQLData\DepotDB.mdf'),
   (FILENAME = N'D:\SQLData\DepotDB_log.ldf')
FOR ATTACH;

Stopping the service also frees the files but it takes every database offline. Microsoft documents the stop steps in SQL Server Configuration Manager and with net stop.

Microsoft recommends placing backups on a separate device from the database files. Cold copies beside the original protect nothing when that disk fails.

Method #3: Recover a Damaged Cold Copy With EmailDoctor (Free Scan, Paid Export)

Cold backups fail the attach when the MDF file is damaged. EmailDoctor SQL Database Recovery scans a duplicate of the file and sends its tables into a fresh database.

Work on a duplicate and never the original. Vendor notes put the trial limit at five objects and a 25 row sample from one table.

Scan the Cold Copy

  1. Install the recovery software and start it. Recovery software home screen
  2. Click Open and locate the copied DepotDB.mdf file. Open button Select MDF file window
  3. Use Quick Scan for a copy taken after a clean detach and Advance Scan for a copy from a crashed server. Scan mode options
  4. Check the detected SQL Server release in the list. SQL Server version list
  5. Study the scan report and browse the tables in the left tree. Scan report Preview of the MDF file objects

Rebuild the Database

  1. Click Export on the toolbar. Export button
  2. Select the SQL Server Database option. Export options
  3. Supply the Server Name and sign in with Windows Authentication. Windows Authentication option
  4. Click Create New Database and type DepotDB_Recovered in the Database Name box. Create New Database option Database name box
  5. Tick the tables and views you need. Database components list
  6. Select With Schema & Data for rows and structure and click Export. Schema and data option
  7. Check the Export Completed window and refresh Databases in SSMS. Export Completed window Recovered database in SQL Server

How to Verify Both Backups?

Microsoft advises that you test every backup because no restore strategy exists until you do. Add CHECKSUM to the backup statement and verify the file.

RESTORE VERIFYONLY
FROM DISK = N'E:\Backups\DepotDB_Hot.bak'
WITH CHECKSUM;

Per Microsoft restore the backup somewhere safe and execute DBCC CHECKDB against it. Attach the cold copy on a test server and execute the same check.

DBCC CHECKDB (N'DepotDB') WITH NO_INFOMSGS;

Which Problems Stop a Backup?

Five problems stop most backups:

ProblemReasonFix
Backup fails during file workAnother session adds a file or shrinks oneWait for that operation to finish
Backup is refused in a scriptThe script opens a transactionExecute BACKUP outside any transaction
Access to the folder is deniedThe startup account lacks folder accessGive the startup account folder access
Detach is refusedActive connections existUse Drop Connections in the dialog
Older backups became uselessFORMAT overwrote the media headerUse INIT instead of FORMAT

Switch to Method #3 on a duplicate when the cold copy refuses to attach.

Frequently Asked Questions

Does a Hot Backup Need Downtime?

No. Microsoft states that SQL Server backs up a database while it is still in use.

Can Users Insert Data During an Online Backup?

Yes. Microsoft states that INSERT and UPDATE and DELETE statements work during a backup.

Can BACKUP Execute Inside a Transaction?

No. Microsoft rejects BACKUP inside both explicit and implicit transactions.

Does FORMAT Preserve Older Backups?

No. Microsoft states that FORMAT makes the existing contents of the volume invalid.

Does CHECKSUM Verify Backup Pages?

Yes. Per Microsoft the backup verifies pages for checksum and generates a checksum for the backup.

Does BACKUP Need Special Permission?

Yes. Three roles have it by default per Microsoft. They are sysadmin and db_owner and db_backupoperator.

Does Detach Delete the Database Files?

No. Detach deletes no files per Microsoft.

Does a Cold Backup Need the Database Offline?

Yes. Copy the files only after you detach the database or stop the service.

Can Recovery Software Open a Damaged Cold Copy?

Yes. Recovery software scans a duplicate of the MDF file and sends its tables into a fresh database.

Does a Trial Copy Export Everything?

No. Vendor notes put the trial limit at five objects and a 25 row sample from one table.

Author’s Verdict

Hot backups protect a busy database every day while offline copies suit planned moves. Choose by how much downtime you can accept.

Add CHECKSUM to every online backup and test one restore. Recovery software matters when a cold copy will not attach.

Store both backups away from the database disk.

  • Hot backups copy an online database with BACKUP DATABASE while users work.
  • Offline copies use detached files and take the database offline.
  • FORMAT makes older backups useless so use INIT.
  • CHECKSUM and a test restore prove a backup works.
  • Recovery software exports a damaged MDF copy into a fresh database.
  • Test every step on a duplicate first.
  Neeraj Kumar

By Neeraj Kumar

Neeraj Kumar is a Principal Technical Architect at EmailDoctor with 19+ years of experience in email migration, cloud migration, data recovery and digital forensics. He guides enterprise teams through Exchange, Office 365 and Google Workspace projects and shares what works as an EmailDoctor writer. Every method in his posts is tested on Windows and Mac before it goes live.