100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

Database Backup & Recovery Cheat Sheet

Database Backup & Recovery Cheat Sheet

Covers full, incremental, and continuous backup strategies, point-in-time recovery, and RTO/RPO planning to protect against data loss.

2 PagesIntermediateMar 18, 2026

PostgreSQL Backup & Restore

Logical and physical backup commands.

bash
# Logical backup: single database, portable across versionspg_dump -U postgres -Fc mydb > mydb_backup.dump# Restore a logical backup into a fresh databasepg_restore -U postgres -d mydb_restored --clean mydb_backup.dump# Physical backup for point-in-time recovery (base + WAL)pg_basebackup -U replicator -D /backups/base -Fp -Xs -P# Point-in-time recovery: restore base backup, then replay WAL to a target time# recovery_target_time = '2026-07-08 03:00:00'# recovery_target_action = 'promote'

MySQL Backup Tools

Logical dumps and hot physical backups.

bash
# Logical backup of a single databasemysqldump -u root -p --single-transaction --routines --triggers mydb > mydb.sql# Restoremysql -u root -p mydb < mydb.sql# Physical hot backup (Percona XtraBackup) - no downtime, supports large datasetsxtrabackup --backup --target-dir=/backups/fullxtrabackup --prepare --target-dir=/backups/fullxtrabackup --copy-back --target-dir=/backups/full

Backup Types

Common backup strategies and their trade-offs.

  • Full backup- A complete copy of the entire database at a point in time; simplest to restore, largest and slowest to create
  • Incremental backup- Captures only changes since the last backup (full or incremental); smaller/faster but restore requires the whole chain
  • Differential backup- Captures changes since the last full backup; larger than incremental but restore only needs the full + latest differential
  • Continuous archiving (WAL/binlog shipping)- Continuously streams the transaction log to backup storage, enabling point-in-time recovery to any second
  • Logical vs physical backup- Logical (pg_dump/mysqldump) exports SQL statements, portable but slower; physical copies raw data files, faster but version/platform specific

RTO & RPO

Metrics that define how much data loss and downtime is acceptable.

  • RPO (Recovery Point Objective)- Maximum acceptable data loss measured in time (e.g., RPO of 5 min means you can lose at most 5 minutes of writes)
  • RTO (Recovery Time Objective)- Maximum acceptable downtime to restore service after a failure
  • 3-2-1 rule- Keep 3 copies of data, on 2 different media types, with 1 copy stored off-site
  • Backup testing- Regularly restoring backups to a scratch environment to verify they are actually usable, not just that the job succeeded
  • Point-in-time recovery (PITR)- Restoring a database to an exact timestamp by replaying transaction logs on top of a base backup

Postgres PITR Recovery Configuration

Restore a base backup and replay WAL to an exact point before a mistake.

bash
# 1. Stop the server and clear the data directory, then restore the base backuprm -rf /var/lib/postgresql/data/*tar -xzf /backups/base/base.tar.gz -C /var/lib/postgresql/data# 2. Create recovery signal file (PG12+) so the server knows to enter recovery modetouch /var/lib/postgresql/data/recovery.signal# 3. Configure recovery target in postgresql.confcat >> /var/lib/postgresql/data/postgresql.conf <<EOFrestore_command = 'cp /backups/wal_archive/%f %p'recovery_target_time = '2026-07-08 03:00:00'recovery_target_action = 'promote'recovery_target_inclusive = falseEOF# 4. Start Postgres - it replays WAL up to the target time then promotes to primarypg_ctl start -D /var/lib/postgresql/data

MySQL Binlog-Based Point-in-Time Recovery

Recover from the last full backup plus binary logs up to just before a bad DELETE.

bash
# Restore the last full logical backupmysql -u root -p mydb < mydb_full_backup.sql# Find the binlog position of the accidental statementmysqlbinlog --start-datetime='2026-07-08 02:00:00' \            --stop-datetime='2026-07-08 02:59:00' \            /var/log/mysql/binlog.000123 | grep -A2 'DELETE FROM orders'# Replay binlogs from the backup point up to (but excluding) the bad statementmysqlbinlog --start-position=4 --stop-position=889213 \            /var/log/mysql/binlog.000123 | mysql -u root -p mydb# Replay the remainder of the binlog after the bad statement's positionmysqlbinlog --start-position=889350 \            /var/log/mysql/binlog.000123 | mysql -u root -p mydb

Automated Restore Drill Script

A scheduled job that restores into a scratch DB and checksums row counts to catch silent backup corruption.

bash
#!/usr/bin/env bashset -euo pipefailBACKUP_FILE=$(ls -t /backups/*.dump | head -1)SCRATCH_DB="restore_drill_$(date +%Y%m%d)"createdb "$SCRATCH_DB"pg_restore -d "$SCRATCH_DB" --no-owner "$BACKUP_FILE"# Compare row counts against a known-good manifest captured at backup timeACTUAL=$(psql -d "$SCRATCH_DB" -tAc "SELECT count(*) FROM orders")EXPECTED=$(cat /backups/manifests/orders_count.txt)if [ "$ACTUAL" -lt "$((EXPECTED * 95 / 100))" ]; then  echo "ALERT: restored row count ($ACTUAL) is >5% below expected ($EXPECTED)" >&2  exit 1fidropdb "$SCRATCH_DB"echo "restore drill passed: $ACTUAL rows verified"

Replication Is Not a Backup

Common misconceptions that turn a small incident into permanent data loss.

  • Streaming replication propagates mistakes too- A DROP TABLE or bad UPDATE replicates to standbys in milliseconds; only a delayed/lagged replica or a real point-in-time-recoverable backup protects against logical errors
  • Delayed replica- A standby configured with recovery_min_apply_delay gives an operator a window (e.g. 6 hours) to catch and stop a bad statement before it applies
  • Snapshot vs backup- A storage-level snapshot (EBS, LVM) is fast but ties you to that storage backend and provider; it is not portable and not a substitute for a tested logical/physical backup
  • Backup encryption at rest- Dumps and WAL archives often contain full customer data; encrypt them (e.g. GPG, SSE-KMS on S3) and separately manage key rotation/escrow
  • Immutable/WORM backup storage- Object-lock or WORM-tier storage prevents ransomware or a compromised admin credential from deleting your only backup copies
  • Cross-region backup replication- A backup stored only in the same region as production doesn't protect against a regional outage or account-level compromise

Common Recovery Scenarios

Matching the failure mode to the right recovery technique.

  • Accidental DROP TABLE / DELETE- Requires PITR (WAL/binlog replay) to a timestamp just before the statement, or restoring from a delayed replica; a plain full backup alone loses everything since the last backup
  • Single corrupted data file / disk failure- Physical backup restore (pg_basebackup/xtrabackup) is fastest; logical restore works but rebuilds indexes from scratch, which is far slower on large tables
  • Ransomware / compromised credentials- Only immutable, air-gapped or offline-copy backups are safe; anything reachable with the compromised credentials must be assumed encrypted or deleted too
  • Schema migration gone wrong- Take an explicit pre-migration snapshot/dump before running DDL; PITR to 'just before the migration' is fragile if application traffic continued writing during the bad migration
  • Full datacenter/region loss- Requires a cross-region replica or cross-region backup copy plus a documented failover runbook; discovering the plan mid-outage is how RTO blows past its target
  • Silent data corruption (bit rot, bad RAID rebuild)- Checksummed backups (pg_dump with --verbose, xtrabackup's built-in checksum) and periodic restore drills are the only reliable detection, since corruption often isn't visible until a query touches the affected page
Pro Tip

An untested backup is not a backup — schedule automated restore drills (e.g., monthly restore-and-checksum jobs) because the most common backup failure mode is discovering a corrupt or incomplete dump only during a real outage.

Was this cheat sheet helpful?

Explore Topics

#DatabaseBackupRecovery#DatabaseBackupRecoveryCheatSheet#Database#Intermediate#PostgreSQLBackupRestore#MySQLBackupTools#BackupTypes#RTORPO#Databases#CheatSheet#SkillVeris

Frequently Asked Questions

21 categories · pick one to explore

Does SkillVeris have a tech blog, and what does it cover?
Yes, the SkillVeris blog has over 500 articles covering AI and machine learning, programming, web development, DevOps, cloud, security, databases and career guidance. Articles are practical and answer-first, and many use the Learn Through Hobbies approach, teaching technical concepts through cricket, music, gaming or cooking analogies. Everything is free to read.
What is the SkillVeris tech glossary and how big is it?
The SkillVeris glossary is a free reference of roughly 2,000-plus technology terms, each with a clear plain-language definition. It spans AI, programming, web, DevOps, cloud, security and database vocabulary, so whenever a lesson, article or job description uses jargon you do not recognise, the glossary gives you a fast, reliable answer.
Are the developer cheat sheets on SkillVeris free to download?
The cheat sheets are completely free to use, like everything else on SkillVeris. Each sheet condenses a language or tool into its essential syntax, commands and patterns for quick reference while coding. They are designed for rapid lookup during real work, complementing the deeper explanations found in study notes and courses.
Which programming references and cheat sheets are available?
Cheat sheets cover the platform's main domains, including programming languages, AI and ML tooling, web development, DevOps, cloud, security and databases, matching the topics of the 37 live courses. Each sheet lists related reading links and hashtags, so you can jump from a quick reference into fuller study notes or blog articles.
How do I find the meaning of a technical term quickly?
Search the SkillVeris glossary, which holds around 2,000-plus terms with concise, plain-language definitions. Each entry gets to the point in its first sentence, then links to related reading like blog posts or study notes for deeper context. It is faster and more consistent than sifting through scattered search results.
Is the SkillVeris blog good for beginners learning to code?
Yes, many blog articles are written specifically for beginners, and the Learn Through Hobbies style makes them unusually approachable: you might learn Python concepts through cricket or understand APIs through cooking. With 500-plus articles across skill levels, beginners can start with fundamentals and keep reading as they advance, entirely free.
Can cheat sheets replace full courses for learning a language?
No, cheat sheets are references, not teaching tools; they assume you already understand the concepts and just need syntax or commands fast. To actually learn a language, take a structured SkillVeris course with its 24–40 lessons and assessments, then keep the cheat sheet beside you while practising in Code Lab.
How often are new blog articles published on SkillVeris?
The blog grows regularly and already exceeds 500 articles, with new posts added as courses launch and technologies evolve. Topics track the platform's catalogue across AI, programming, web development, DevOps, cloud and security, so checking the Blog section periodically surfaces fresh tutorials, explainers and career-focused pieces, all free to read.
Does the glossary cover AI and machine learning terms?
Yes, AI and machine learning vocabulary is a major part of the roughly 2,000-plus term glossary, covering everything from foundational terms to modern concepts around LLMs, RAG and MLOps. Definitions are plain-language and answer-first, which helps when dense AI papers or course lessons throw unfamiliar jargon at you.
Are there cheat sheets for interview preparation?
Cheat sheets work well as interview-day refreshers because they compress syntax, commands and key concepts into scannable references. For dedicated preparation, combine them with the SkillVeris interview questions feature, which includes readiness scoring, plus study notes for depth. Reviewing a relevant cheat sheet just before an interview steadies recall under pressure.
Can I read the tech blog without signing up?
Yes, the blog is freely readable, and SkillVeris never charges for content. All 500-plus articles are open, covering tutorials, concept explainers and career advice. Creating a free account adds value elsewhere on the platform, like course progress tracking and certificates, but reading the blog requires no commitment at all.
How is the SkillVeris glossary different from Wikipedia?
The glossary is purpose-built for learners: definitions are short, plain-language and answer-first, sized for a quick lookup mid-lesson rather than a deep encyclopedic read. Entries also cross-link to related SkillVeris study notes, blog posts and courses, so a definition becomes a doorway into structured learning instead of a dead end.
Do blog articles use the Learn Through Hobbies method?
Many blog articles teach technical topics through hobby analogies, a hallmark of the SkillVeris blog, so you will find articles explaining programming through cricket, machine learning through music, or system design through cooking. The analogy is the teaching device; the article still delivers the real technical concept underneath.
Where can I find quick programming references while coding?
Open the SkillVeris cheat sheets, which are built exactly for that moment: compact, scannable references for syntax, commands and common patterns across languages and tools. Keep the relevant sheet in a browser tab while you work in Code Lab or your own editor, and dip into the glossary for terminology.
Is there a glossary entry for terms I meet in job descriptions?
Very likely yes, with roughly 2,000-plus terms across AI, programming, web, DevOps, cloud, security and databases, the glossary covers most jargon that appears in tech job descriptions. Decoding a listing this way helps you judge role fit honestly and prepares you to discuss those terms in interviews.
Are the blog articles written for the Indian tech audience?
The blog serves Indian learners plus a worldwide audience. Content stays globally relevant while acknowledging realities that matter in India, such as free access being essential for students and freshers, and career guidance that connects naturally to the SkillVeris jobs portal, which aggregates roles across India, UK, USA, Germany and Remote.
Can I suggest a topic for the blog or glossary?
SkillVeris content grows in response to what learners need, so feedback is welcome through the platform's support channels. If a term is missing from the glossary or a topic deserves an article, telling the team helps prioritise it. Meanwhile, the AI Mentor can answer the question immediately, 24/7, at any depth.
Do cheat sheets and glossary entries link to deeper learning?
Yes, every cheat sheet and glossary entry carries related reading links into study notes, blog articles and courses, plus concept hashtags for discovering similar content. This cross-linking means a thirty-second lookup can smoothly become a structured learning session whenever you decide you want more than a quick answer.
What makes SkillVeris programming references trustworthy?
The references are written to strict internal quality standards, kept consistent with the platform's 37 live courses, and never padded with invented statistics or hype. Definitions and cheat sheets are reviewed against the same content contracts that govern courses, and the answer-first style makes any inaccuracy easy to spot and correct.
How do the blog, glossary and cheat sheets fit into my learning routine?
Use them as satellites around your main course: read blog articles for context and motivation, hit the glossary the instant jargon appears, and keep cheat sheets open while coding. Together with study notes, Code Lab and the 24/7 AI Mentor, they turn passive reading into a complete, free learning system.

What Learners Say

Real journeys from the SkillVeris community — swipe for more.

SkillVeris taught me Python through Cricket. Now I’m building real projects and feeling confident!
Arjun S. · B.Tech Student
The best platform for hobby-based learning. Concepts finally stick.
Priya R. · Data Analyst
I went from zero coding to a portfolio of projects — all by learning through my love for gaming. Landed my first internship!
Kabir M. · CS Undergraduate
Trending Topics50 popular tags — tap to explore
Trending CoursesAll 37 free courses — tap to browse