Knowledge Base – Database Backup

Home

Comprehensive Database Backup Guide

This article provides step‑by‑step instructions, best practices, and tools for creating reliable backups of your relational databases.

Backup Methods
Common Commands
Schedule Backup

Backup Strategies

  • Full Dump: Captures the entire database at a point in time.
  • Incremental: Backs up only changes since the last backup.
  • Logical vs Physical: Logical (SQL) vs Physical (binary files).
  • Point‑in‑Time Recovery (PITR): Use WAL/transaction logs for precise restore.

Example Commands

MySQL/MariaDB (Full Dump)

mysqldump -u <user> -p<password> --single-transaction --quick <database_name> > /backups/db_$(date +%F).sql

PostgreSQL (Full Dump)

pg_dump -U <user> -F c -b -v -f /backups/db_$(date +%F).backup <database_name>

MongoDB (Dump)

mongodump --uri="mongodb://user:pass@host:27017/dbname" --out /backups/mongo_$(date +%F)

Schedule a Backup

Best Practices

  1. Store backups off‑site or in a cloud bucket.
  2. Encrypt backup files at rest.
  3. Verify backups regularly with test restores.
  4. Document retention policies and comply with regulations.
  5. Automate cleanup of old backup files.