# Database Backups and Restores

> Choose backup methods, schedules and retention that meet your RPO, and prove them by restoring regularly. Free notes, key concepts, resources and a mini...

Canonical: https://www.internhack.in/roadmaps/tracks/devops/database-backups
Last updated: 2026-11-28

Choose backup methods, schedules and retention that meet your RPO, and prove them by restoring regularly.

Intermediate · about 5 hours · difficulty 3/5

Learn first: [Capacity Planning, High Availability and Disaster Recovery](https://www.internhack.in/roadmaps/tracks/devops/reliability-capacity)

Nobody wants backups; everybody wants restores. A backup you have never restored is an assumption. This topic makes sure your data can come back.

### Backup types

- **Logical** dumps (`pg_dump`, `mysqldump`, `mongodump`): portable, table-level restores, slow on large databases.
- **Physical** backups (`pg_basebackup`, Percona XtraBackup, storage snapshots): fast full copies of data files.
- **Point-in-time recovery (PITR)**: a base backup plus continuous **WAL** or **binlog** archiving lets you restore to any second, which is how you recover from "someone ran DELETE without WHERE at 14:03".
- **Managed services** (RDS, Cloud SQL, Azure Database) automate snapshots and PITR within a retention window; you still own cross-region copies and restore testing.

### A sound backup policy

- Match frequency and PITR to the **RPO** agreed with the business.
- Follow **3-2-1**: three copies, two media or services, one off-site. In cloud terms, another region and ideally another account.
- Encrypt backups and restrict who can delete them; use **immutable** or object-locked storage against ransomware and mistakes.
- Keep retention for compliance and cost, with lifecycle rules to cheaper tiers.

### Restore drills

Automate a scheduled restore into a scratch environment, run sanity queries (row counts, latest timestamps), and record how long it took. That duration is your real **RTO**. Tools such as **pgBackRest**, **WAL-G** and **Velero** (for Kubernetes volumes) help automate both sides.

**Good enough to move on:** you can configure PITR for Postgres, restore to a specific timestamp into a new instance, and run a scheduled restore test that reports its duration.

## Key concepts

- **Logical vs physical backups**
- **Point-in-time recovery with WAL/binlog**
- **Managed database snapshots**
- **3-2-1 rule and cross-region copies**
- **Immutable and encrypted backups**
- **Automated restore drills**
- **pgBackRest, WAL-G and Velero**

## Mini project

Run Postgres with WAL archiving to object storage, insert data, simulate an accidental delete, restore to the second before it into a new instance, and script the whole drill so it runs weekly.

## Check yourself

Nightly snapshots are taken at 02:00. A bad migration corrupts data at 16:00. How much data do you lose without PITR, and how does PITR change that?

## Free resources

- [PostgreSQL: backup and restore](https://www.postgresql.org/docs/current/backup.html) (PostgreSQL)
- [Amazon RDS backups](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_WorkingWithAutomatedBackups.html) (AWS)
- [Velero documentation](https://velero.io/docs/) (Velero)

Previous: [Policy as Code and Compliance](https://www.internhack.in/roadmaps/tracks/devops/policy-as-code) · Next: [Replication, Failover and Connection Management](https://www.internhack.in/roadmaps/tracks/devops/database-replication-ha)

## More in Running Databases in Production

- [Database Backups and Restores](https://www.internhack.in/roadmaps/tracks/devops/database-backups)
- [Replication, Failover and Connection Management](https://www.internhack.in/roadmaps/tracks/devops/database-replication-ha)
- [Zero-Downtime Schema Migrations](https://www.internhack.in/roadmaps/tracks/devops/schema-migrations)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [DevOps Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/devops)
