Pcornel
Databases

Backup, Restore & Recovery

Cheat sheet · https://pcornel.dk/topic.php?topic=6093

Back to the Topic

Answer

Backup, restore and recovery protect data: full, differential and log/WAL backups; logical dumps vs physical copies; point-in-time recovery; and regular restore tests.

Remember

Define RPO/RTO first. Keep backups off the server and immutable. A backup is proven only by restoring it.

First checks

  • SELECT database_name,MAX(backup_finish_date) FROM msdb.dbo.backupset GROUP BY database_name; — first check for this topic
  • psql -c "SELECT now(), version();" — PostgreSQL reachable and version
  • mysql -e "SELECT NOW(), VERSION();" — MariaDB/MySQL reachable and version
  • sqlcmd -S <server> -Q "SELECT @@VERSION" — SQL Server reachable and version

Verify in this order

full + incremental/log backups → stored off-host → restore + replay → verified

Where it usually breaks

Common failures are missing log segments, inconsistent filesystem-only copies, untested encryption keys/credentials, retention deleting a required base/log chain, backups stored on the same failure domain and assuming snapshot success equals application-consistent recovery.

Backup, Restore & Recovery verification boundary matrix

BoundaryInspectHealthy interpretationDo not infer
IntentLogical vs physical backupIntended object/scope is explicit and versioned where relevantIntent is already effective
Owning runtime/control planeFull/incremental/differential boundaries / Transaction/WAL/binlog recoveryOwner accepts and reports the expected object stateDownstream dependencies are healthy
Effective statePoint-in-time recoveryIndependent read-back matches the intended stateEvery client sees the same result
Consumer outcomeRPO and RTOThe original bounded check succeeds in the same time windowProduction correctness outside this scope

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6093

Confirmation

Confirm action

Continue?