The recovery model is the first decision and it is frequently made by accident, because FULL is the default and inherited from model.
In SIMPLE, the log truncates at each checkpoint. You cannot take log backups, so you cannot restore to a point in time - your exposure is everything since the last full or differential backup. The log does not grow. It is right for a development database or a warehouse reloaded nightly.
In FULL, the log is retained until a log backup is taken. You can restore to any point in time. And if you never take log backups, the log grows until the disk fills - which is the single most common SQL Server incident, and it is caused by setting FULL and only taking full backups.
BULK_LOGGED is a variant for bulk operations that gives up point-in-time recovery within those operations.
The restore chain. A full backup is a complete copy. A differential holds everything changed since the last full - not since the last differential, which people assume. A log backup holds the log records since the previous log backup, and these form a chain: break it, by taking a full backup with COPY_ONLY omitted on an ad-hoc tool or by switching recovery models, and you cannot restore past the break.
To restore to a point in time: the last full, then the latest differential, then every log backup in order, all with NORECOVERY except the last, which uses STOPAT and RECOVERY.
Always On availability groups replicate at the database level to replicas that can be synchronous (zero data loss, write latency paid) or asynchronous (no latency cost, non-zero RPO). A listener gives clients a single name that follows the primary. Automatic failover requires a synchronous replica and a quorum.
Test the failover. An availability group that has never failed over is a configuration, not a capability. The things that break are invariably outside the database: logins that exist only on the old primary, Agent jobs that were not scripted, linked servers, and connection strings that lack MultiSubnetFailover=True.
Laboratory exercise 5 - lose it and get it back.
Set the database to FULL and establish a backup schedule: full, differential, and frequent log backups. Load data continuously while this runs.
Cause logical damage at a recorded time - an UPDATE with no WHERE. Restore to the moment before it, using the complete chain. Time the whole restore and compute the achieved RPO and RTO.
Then demonstrate the log-growth incident: switch another database to FULL, take only full backups, write continuously, and watch the log grow. Diagnose it from log_reuse_wait_desc.
If your environment allows, configure a two-replica availability group and perform both a manual failover and a simulated primary failure. If it does not, produce a design exercise instead: the topology, the synchronous/asynchronous decision with its RPO consequence, and the failover runbook.
Deliverable: a recovery runbook usable under pressure, the measured RPO and RTO, the log-growth diagnosis, and verification evidence - row counts and checksums proving the data is correct, not merely that the server started.
-- ------------------------------------------------------------------
-- The recovery model decides what restores are POSSIBLE.
-- ------------------------------------------------------------------
SELECT name, recovery_model_desc, log_reuse_wait_desc
FROM sys.databases;
--
-- log_reuse_wait_desc is the diagnosis when a log will not shrink:
-- LOG_BACKUP FULL model, no log backups <- the usual one
-- ACTIVE_TRANSACTION someone left a transaction open
-- REPLICATION a replication reader is behind
-- AVAILABILITY_REPLICA a secondary is not keeping up
ALTER DATABASE SalesWorkshop SET RECOVERY FULL;
-- ------------------------------------------------------------------
-- The chain. Order matters and so does the WITH clause.
-- ------------------------------------------------------------------
BACKUP DATABASE SalesWorkshop
TO DISK = '/backup/sw_full.bak'
WITH INIT, COMPRESSION, CHECKSUM, STATS = 10;
-- ^^^^^^^^ CHECKSUM verifies pages as they are read. A backup of
-- already-corrupt pages restores corruption faithfully.
BACKUP DATABASE SalesWorkshop
TO DISK = '/backup/sw_diff.bak'
WITH DIFFERENTIAL, INIT, COMPRESSION, CHECKSUM;
-- A differential contains everything changed since the last FULL -
-- not since the last differential. They grow until the next full.
BACKUP LOG SalesWorkshop
TO DISK = '/backup/sw_log_001.trn' WITH INIT, COMPRESSION, CHECKSUM;
-- Every 5-15 minutes in production. This interval IS your RPO.
-- COPY_ONLY for an ad-hoc backup, so you do not break the chain that
-- the scheduled job depends on:
BACKUP DATABASE SalesWorkshop
TO DISK = '/backup/sw_adhoc.bak' WITH COPY_ONLY, INIT;
-- Verify it is restorable. A backup nobody has read is a file.
RESTORE VERIFYONLY FROM DISK = '/backup/sw_full.bak' WITH CHECKSUM;
RESTORE HEADERONLY FROM DISK = '/backup/sw_full.bak';
-- ------------------------------------------------------------------
-- Point-in-time restore. The damage happened at 14:05.
-- ------------------------------------------------------------------
-- Capture the tail of the log FIRST, or you lose everything since the
-- last log backup:
BACKUP LOG SalesWorkshop TO DISK = '/backup/sw_tail.trn'
WITH NORECOVERY, INIT;
RESTORE DATABASE SalesWorkshop FROM DISK = '/backup/sw_full.bak'
WITH NORECOVERY, REPLACE;
RESTORE DATABASE SalesWorkshop FROM DISK = '/backup/sw_diff.bak'
WITH NORECOVERY;
RESTORE LOG SalesWorkshop FROM DISK = '/backup/sw_log_001.trn'
WITH NORECOVERY;
RESTORE LOG SalesWorkshop FROM DISK = '/backup/sw_tail.trn'
WITH STOPAT = '2026-11-30T14:04:00', RECOVERY;
-- ^^^^^^ every restore NORECOVERY except the last.
-- RECOVERY runs recovery and opens the database; after that you
-- cannot apply more log, and the chain must be started again.
-- Then VERIFY with a query, not with optimism:
SELECT COUNT(*) AS orders, SUM(quantity * unit_price) AS revenue
FROM sales.order_line2;
DBCC CHECKDB('SalesWorkshop') WITH NO_INFOMSGS, ALL_ERRORMSGS;
-- ------------------------------------------------------------------
-- Always On availability groups.
-- ------------------------------------------------------------------
-- CREATE AVAILABILITY GROUP SalesAG
-- WITH (AUTOMATED_BACKUP_PREFERENCE = SECONDARY)
-- FOR DATABASE SalesWorkshop
-- REPLICA ON
-- 'NODE1' WITH (ENDPOINT_URL = 'TCP://node1:5022',
-- AVAILABILITY_MODE = SYNCHRONOUS_COMMIT,
-- FAILOVER_MODE = AUTOMATIC,
-- SECONDARY_ROLE (ALLOW_CONNECTIONS = READ_ONLY)),
-- 'NODE2' WITH (ENDPOINT_URL = 'TCP://node2:5022',
-- AVAILABILITY_MODE = SYNCHRONOUS_COMMIT,
-- FAILOVER_MODE = AUTOMATIC);
--
-- SYNCHRONOUS_COMMIT zero data loss; every commit waits for the
-- secondary. Automatic failover needs this.
-- ASYNCHRONOUS_COMMIT no write latency; RPO > 0, measured below.
SELECT ag.name, ar.replica_server_name, ar.availability_mode_desc,
ar.failover_mode_desc, rs.synchronization_health_desc,
rs.last_commit_time
FROM sys.availability_groups AS ag
JOIN sys.availability_replicas AS ar ON ar.group_id = ag.group_id
JOIN sys.dm_hadr_availability_replica_states AS rs
ON rs.replica_id = ar.replica_id;
-- The lag that IS your RPO on an async replica:
SELECT DB_NAME(database_id) AS db, log_send_queue_size,
redo_queue_size, last_commit_time
FROM sys.dm_hadr_database_replica_states;
-- ALTER AVAILABILITY GROUP SalesAG FAILOVER; -- planned
-- ALTER AVAILABILITY GROUP SalesAG FORCE_FAILOVER_ALLOW_DATA_LOSS;
--
-- What actually breaks at failover, every time, and is never in the
-- database: logins that exist only on the old primary (script them
-- with their SIDs), Agent jobs, linked servers, certificates, and
-- connection strings missing MultiSubnetFailover=True.
Discussion
No questions on this topic yet. Sign in to ask the first one.